public override async Task <ActionResult <IList <TEntity> > > GetAsync() { IList <TEntity> cachedModels = await GlobalCache.GetAsync(Request).ConfigureAwait(false); if (cachedModels != null) { return(cachedModels.ToList()); } var result = await base.GetAsync().ConfigureAwait(false); if (result.Result is OkResult) { await GlobalCache.AddAsync(Request, result.Value).ConfigureAwait(false); } return(result); }
public override async Task <ActionResult <TEntity> > GetAsync([FromRoute] TKey id) { TEntity model = await GlobalCache.FindAsync(Request).ConfigureAwait(false); if (model != null) { return(model); } var result = await base.GetAsync(id).ConfigureAwait(false); if (result.Result is OkResult) { await GlobalCache.AddAsync(Request, result.Value).ConfigureAwait(false); } return(result); }