public async Task <Channel> GetByIdAsync(int id) { return(await _distributedCache.AddOrGetAsync( GetChannelIdKey(id), TimeSpan.FromDays(7), async token => await _dbContext.Channels .Where(c => c.Id == id) .ProjectTo <Channel>(_mapper.ConfigurationProvider) .FirstOrDefaultAsync(token), CancellationToken.None)); }
public async Task <IReadOnlyCollection <UrlReferrer> > GetAllAsync(bool isDeleted = false) { if (isDeleted) { return(await GetFilteredAsync(r => r.IsDeleted == isDeleted)); } return(await _distributedCache.AddOrGetAsync( WhiteListCacheKey, TimeSpan.FromDays(7), async token => await GetFilteredAsync(r => r.IsDeleted == isDeleted), CancellationToken.None)); }