|
|
|
@ -25,18 +25,12 @@ namespace Expedience.Infrastructure
|
|
|
|
public async Task<List<DutyCompletionRecord>> GetDutyCompletionRecords(string expac, CancellationToken cancellationToken)
|
|
|
|
public async Task<List<DutyCompletionRecord>> GetDutyCompletionRecords(string expac, CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var cacheKey = $"xpd-dcr-{expac}";
|
|
|
|
var cacheKey = $"xpd-dcr-{expac}";
|
|
|
|
if (_memcachedClient.TryGet<List<DutyCompletionRecord>>(cacheKey, out var cachedValue))
|
|
|
|
var cacheSeconds = 600;
|
|
|
|
{
|
|
|
|
var records = await _memcachedClient.GetValueOrCreateAsync(cacheKey, cacheSeconds,
|
|
|
|
return cachedValue;
|
|
|
|
async () => await _dbContext.DutyCompletionRecords.FromSqlInterpolated($"SELECT * FROM public.get_dutycompletionrecords({expac})")
|
|
|
|
}
|
|
|
|
.ToListAsync());
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
return records;
|
|
|
|
var records = await _dbContext.DutyCompletionRecords.FromSqlInterpolated($"SELECT * FROM public.get_dutycompletionrecords({expac})")
|
|
|
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
await _memcachedClient.AddAsync(cacheKey, records, TimeSpan.FromMinutes(10));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return records;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
public void Dispose()
|
|
|
|
|