public async Task <List <T> > GetAllAsync(List <string> keys) { var notInCacheKeys = new List <string>(); var result = new List <T>(); foreach (var key in keys) { if (_cache.TryGetValue(key, out var item)) { result.Add(item); } else { notInCacheKeys.Add(key); } } if (notInCacheKeys.Count > 0) { var resultFromDb = await _stateStoreImplementation.GetAllAsync(notInCacheKeys); if (resultFromDb != null) { result.AddRange(resultFromDb); } } return(result); }