public async Task <T> GetFromSiteIdAsync <T>(string siteId, string type) { var keyValue = Items.FirstOrDefault(s => s.Value.SiteId == siteId && s.Value.Type == type); var cacheItem = keyValue.Value; if (cacheItem == null) { var builder = Builders <CacheItem> .Filter; var filter = builder.Eq(p => p.SiteId, siteId) & builder.Eq(p => p.Type, type); cacheItem = await _collection.Find(filter).FirstOrDefaultAsync(); AddMemoryCache(cacheItem); } else { return(JsonConvert.DeserializeObject <T>(cacheItem.Value)); } return(default(T)); }