Пример #1
0
        public async Task RemoveAsync(string cacheItemId)
        {
            var builder = Builders <CacheItem> .Filter;
            var filter  = builder.Eq(p => p.Guid, new Guid(cacheItemId));
            await _collection.DeleteOneAsync(filter);

            var itemsToRemove = Items.Where(s => s.Value.Id == cacheItemId).ToList();

            foreach (var cacheItem in itemsToRemove)
            {
                // TODO
                CacheItem ci;
                Items.TryRemove(CacheItem.GetKey(cacheItem.Value), out ci);
            }
        }
Пример #2
0
        public async Task DeleteAsync(string siteId)
        {
            var builder = Builders <CacheItem> .Filter;
            var filter  = builder.Eq(p => p.SiteId, siteId);
            await _collection.DeleteManyAsync(filter);

            var itemsToRemove = Items.Where(s => s.Value.SiteId == siteId).ToList();

            foreach (var cacheItem in itemsToRemove)
            {
                // TODO
                CacheItem ci;
                Items.TryRemove(CacheItem.GetKey(cacheItem.Value), out ci);
            }
        }