public async Task <List <string[]> > GetTradeHistory(int tradePairId) { var cacheResult = await CacheService.GetOrSetHybridAsync(CacheKey.ExchangeTradeHistory(tradePairId), TimeSpan.FromMinutes(60), async() => { using (var context = ExchangeDataContextFactory.CreateReadOnlyContext()) { var query = await context.TradeHistory .AsNoTracking() .Where(x => x.TradePairId == tradePairId).OrderByDescending(x => x.Id).Take(100).Select(x => new { x.Timestamp, x.Type, x.Rate, x.Amount }).ToListNoLockAsync().ConfigureAwait(false); return(query.Select(x => new[] { x.Timestamp.ToString(), x.Type.ToString(), x.Rate.ToString("F8"), x.Amount.ToString("F8"), (x.Amount *x.Rate).ToString("F8") }).ToList()); } }).ConfigureAwait(false); return(cacheResult); }
private async Task ClearCache(int tradePairId) { await CacheService.InvalidateAsync ( CacheKey.ExchangeTradeHistory(tradePairId), CacheKey.ExchangeOrderBook(tradePairId), //CacheKey.ExchangeStockChart(tradePairId, 30), CacheKey.ExchangeDepthChart(tradePairId), CacheKey.ApiMarketHistory(tradePairId, 24) ); }