This commit is contained in:
tanglong 2025-07-07 13:17:45 +08:00
parent d6d2020f50
commit c752ff5dfc
8 changed files with 17 additions and 6 deletions

View File

@ -147,11 +147,22 @@ namespace YD_AllHeartRates.Api.Services.Impl
var now = DateTime.Now;
var tenMinutesAgo = now.AddMinutes(-10);
// 班级学生列表
var studentList = await _sportsContext.Student
// 1. 构建缓存 key
string studentListKey = $"students:{schoolCode}:{classId}";
// 2. 尝试从缓存获取
var studentList = _caching.Get<List<S_Student>>(studentListKey);
// 3. 如果缓存没有 → 查询数据库 + 写入缓存
if (studentList == null)
{
studentList = await _sportsContext.Student
.Where(x => x.ClassId == classId && x.SchoolCode == schoolCode && x.StudentStatus == 1)
.ToListAsync();
_caching.AddObject(studentListKey, studentList, 28800); // 缓存 8 小时
}
int warmUp = 0, low = 0, medium = 0, high = 0, warning = 0;
foreach (var student in studentList)

View File

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_AllHeartRates.Api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ee9116aea22701bf6d184657d96c4e24b2bc0095")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d6d2020f505a0bb193e3e5458b5eea828a0319bf")]
[assembly: System.Reflection.AssemblyProductAttribute("YD_AllHeartRates.Api")]
[assembly: System.Reflection.AssemblyTitleAttribute("YD_AllHeartRates.Api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
1c24cdf25780b49d3cd275d101f9545d4bc591310051a502fe2c6f782554626d
a530ed2a87c580cfd903afba773c538f851e82dd409265bf8c14464bcc334d6f