public void RemoveRange(IEnumerable <RecipeDetails> recipeDetails)
        {
            var keys = recipeDetails.Select(x => x.Id.Value
                                            .ToDictionaryKey(nameof(RecipeDetails)));

            _cachingProvider.RemoveAll(keys);
        }
        protected virtual void GetAll_Should_Succeed()
        {
            _provider.RemoveAll(new List <string> {
                "getall:key:1", "getall:key:2"
            });
            var dict = GetMultiDict("getall:");

            _provider.SetAll(dict, _defaultTs);

            var res = _provider.GetAll <string>(new List <string> {
                "getall:key:1", "getall:key:2"
            });

            Assert.Equal(2, res.Count);

            Assert.True(res.Select(x => x.Key).Contains("getall:key:1"));
            Assert.True(res.Select(x => x.Key).Contains("getall:key:2"));
            Assert.Equal(res.Where(x => x.Key == "getall:key:1").Select(x => x.Value).FirstOrDefault().Value, "value1");
            Assert.Equal(res.Where(x => x.Key == "getall:key:2").Select(x => x.Value).FirstOrDefault().Value, "value2");
        }
        /// <summary>
        /// Removes all.
        /// </summary>
        /// <param name="cacheKeys">Cache keys.</param>
        public void RemoveAll(IEnumerable <string> cacheKeys)
        {
            ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys));

            _localCache.RemoveAll(cacheKeys);

            _distributedCache.RemoveAllAsync(cacheKeys);

            //send message to bus in order to notify other clients.
            _bus.Publish(_options.TopicName, new EasyCachingMessage {
                Id = _cacheId, CacheKeys = cacheKeys.ToArray()
            });
        }
示例#4
0
        /// <summary>
        /// Removes all.
        /// </summary>
        /// <param name="cacheKeys">Cache keys.</param>
        public void RemoveAll(IEnumerable <string> cacheKeys)
        {
            ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys));

            _localCachingProvider.RemoveAll(cacheKeys);

            try
            {
                _distributedCachingProvider.RemoveAll(cacheKeys);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// Removes all.
        /// </summary>
        /// <param name="cacheKeys">Cache keys.</param>
        public void RemoveAll(IEnumerable <string> cacheKeys)
        {
            ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys));

            try
            {
                _distributedCache.RemoveAllAsync(cacheKeys);
            }
            catch (Exception ex)
            {
                LogMessage($"remove all from distributed provider error [{string.Join(",", cacheKeys)}]", ex);
            }

            _localCache.RemoveAll(cacheKeys);

            // send message to bus in order to notify other clients.
            _busSyncWrap.Execute(() => _bus.Publish(_options.TopicName, new EasyCachingMessage {
                Id = _cacheId, CacheKeys = cacheKeys.ToArray()
            }));
        }
示例#6
0
 /// <summary>
 /// Removes all.
 /// </summary>
 /// <param name="cacheKeys">Cache keys.</param>
 public void RemoveAll(IEnumerable <string> cacheKeys)
 {
     _easyCachingProvider.RemoveAll(cacheKeys);
 }