private async Task <List <TradeHistoryData> > GetOrCacheTradeHistory() { var cacheResult = await CacheService.GetOrSetHybridAsync(CacheKey.ExchangeTradeHistoryData(), TimeSpan.FromMinutes(1), async() => { using (var context = ExchangeDataContextFactory.CreateReadOnlyContext()) { var lastTime = DateTime.UtcNow.AddHours(-24); var results = await context.TradeHistory .AsNoTracking() .Where(tp => tp.TradePair.Status != TradePairStatus.Closed && tp.Timestamp > lastTime) .Select(x => new TradeHistoryData { TradePairId = x.TradePairId, Amount = x.Amount, Rate = x.Rate, Timestamp = x.Timestamp }).ToListNoLockAsync(); return(results.OrderBy(x => x.Timestamp).ToList()); } }).ConfigureAwait(false); return(cacheResult); }