public virtual async Task <List <T> > GetAllAsync(bool skipDatabaseConsistencyCheck = false) { // If this is the first time the GetAllAsync has been called, we return 0, despite the fact that there might be some in the cache. // This is because we want to force the call to the database to ensure that we have a true "all" which will also then populate the cache. if (skipDatabaseConsistencyCheck) { var allItemsNonDbCheck = await _appCache.GetAllItemsInPartitionAsync <T>(PartitionNameFormatter()).ConfigureAwait(false); return(allItemsNonDbCheck); } var lastCallToGetAllKey = ComposeLastCallToGetAllCacheKey(); var containsKey = await _appCache.ContainsAsync(lastCallToGetAllKey).ConfigureAwait(false); if (containsKey) { await _appCache.AddOrUpdateAsync(lastCallToGetAllKey, DateTimeOffset.UtcNow, TimeSpan.FromDays(2)).ConfigureAwait(false); var response = await _appCache.GetAllItemsInPartitionAsync <T>(PartitionNameFormatter()).ConfigureAwait(false); return(response); } await _appCache.AddOrUpdateAsync(lastCallToGetAllKey, DateTimeOffset.UtcNow, TimeSpan.FromDays(2)).ConfigureAwait(false); return(new List <T>()); }