修改缓存

Uat_Study
he 2023-10-12 13:49:13 +08:00
parent 8b124e1c60
commit a53626b66c
1 changed files with 11 additions and 3 deletions

View File

@ -15,6 +15,7 @@ using Newtonsoft.Json.Linq;
using Microsoft.Extensions.Caching.Memory;
using IRaCIS.Core.Application.Filter;
using DocumentFormat.OpenXml.Drawing;
using EasyCaching.Core;
using Quartz;
using IRaCIS.Application.Services.BackGroundJob;
@ -47,6 +48,7 @@ namespace IRaCIS.Application.Services
private readonly IRepository<OrganInfo> _organInfoRepository;
private readonly IRepository<TrialDocument> _trialDocumentRepository;
private readonly IRepository<User> _userRepository;
private readonly IEasyCachingProvider _provider;
private readonly IRepository<ReadingCustomTag> _readingCustomTagRepository;
private readonly IRepository<ReadingSystemCriterionDictionary> _readingCriterionDictionaryRepository;
private readonly IRepository<ReadingTrialCriterionDictionary> _readingTrialCriterionDictionaryRepository;
@ -87,6 +89,7 @@ namespace IRaCIS.Application.Services
IRepository<OrganInfo> organInfoRepository,
IRepository<TrialDocument> trialDocumentRepository,
IRepository<User> userRepository,
IEasyCachingProvider provider,
IRepository<ReadingCustomTag> readingCustomTagRepository,
IMemoryCache cache,
IRepository<ReadingSystemCriterionDictionary> readingCriterionDictionaryRepository,
@ -127,6 +130,7 @@ namespace IRaCIS.Application.Services
this._organInfoRepository = organInfoRepository;
this._trialDocumentRepository = trialDocumentRepository;
this._userRepository = userRepository;
this._provider = provider;
this._readingCustomTagRepository = readingCustomTagRepository;
this._readingCriterionDictionaryRepository = readingCriterionDictionaryRepository;
this._tumorAssessmentRepository = tumorAssessmentRepository;
@ -2470,10 +2474,13 @@ namespace IRaCIS.Application.Services
public async Task VerifyReadingRestTime()
{
var cacheKey = _userInfo.Id.ToString();
var value = _cache.Get(cacheKey);
var value = _provider.Get<string>(cacheKey).Value;
if (value == null)
{
_cache.Set(cacheKey, DateTime.Now.ToString(), TimeSpan.FromHours(5));
_provider.Set(cacheKey, DateTime.Now.ToString(), TimeSpan.FromHours(5));
// _cache.Set(cacheKey, DateTime.Now.ToString(), TimeSpan.FromHours(5));
}
else
@ -2488,7 +2495,8 @@ namespace IRaCIS.Application.Services
else if (timespanMin > 140)
{
cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 140))) * 140);
_cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
_provider.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
// _cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
}
#endregion