|
|
|
@ -26,27 +26,17 @@ 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}";
|
|
|
|
|
|
|
|
var cacheSeconds = 600;
|
|
|
|
if (_memcachedClient.TryGet<string>(cacheKey, out var cachedRecords))
|
|
|
|
var records = await _memcachedClient.GetValueOrCreateAsync(cacheKey, cacheSeconds,
|
|
|
|
{
|
|
|
|
async () => await _dbContext.DutyCompletionRecords.FromSqlInterpolated($"SELECT * FROM public.get_dutycompletionrecords({expac})")
|
|
|
|
return JsonConvert.DeserializeObject<List<DutyCompletionRecord>>(cachedRecords);
|
|
|
|
.ToListAsync());
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var records = await _dbContext.DutyCompletionRecords.FromSqlInterpolated($"SELECT * FROM public.get_dutycompletionrecords({expac})")
|
|
|
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.SerializeObject(records);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _memcachedClient.AddAsync(cacheKey, json, TimeSpan.FromMinutes(10));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return records;
|
|
|
|
return records;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_memcachedClient.Dispose();
|
|
|
|
//_memcachedClient.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|