Ejemplo n.º 1
0
        protected virtual void SetAll_Should_Succeed()
        {
            var dict = GetMultiDict("setall:");

            _provider.SetAll(dict, _defaultTs);

            var res1 = _provider.Get <string>("setall:key:1");
            var res2 = _provider.Get <string>("setall:key:2");

            Assert.Equal("value1", res1.Value);
            Assert.Equal("value2", res2.Value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets all.
        /// </summary>
        /// <param name="values">Values.</param>
        /// <param name="expiration">Expiration.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public void SetAll <T>(IDictionary <string, T> values, TimeSpan expiration) where T : class
        {
            ArgumentCheck.NotNegativeOrZero(expiration, nameof(expiration));
            ArgumentCheck.NotNullAndCountGTZero(values, nameof(values));

            _localCachingProvider.SetAll(values, expiration);

            try
            {
                _distributedCachingProvider.SetAll(values, expiration);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// Sets all.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="expiration">Expiration.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public void SetAll <T>(IDictionary <string, T> value, TimeSpan expiration)
        {
            _localCache.SetAll(value, expiration);

            try
            {
                _distributedCache.SetAll(value, expiration);
            }
            catch (Exception ex)
            {
                LogMessage($"set all from distributed provider error [{string.Join(",", value.Keys)}]", ex);
            }

            // send message to bus
            _busSyncWrap.Execute(() => _bus.Publish(_options.TopicName, new EasyCachingMessage {
                Id = _cacheId, CacheKeys = value.Keys.ToArray(), IsPrefix = false
            }));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets all.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="expiration">Expiration.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 public void SetAll <T>(IDictionary <string, T> value, TimeSpan expiration)
 {
     _distributedCache.SetAll(value, expiration);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Sets all.
        /// </summary>
        /// <typeparam name="T">Type of cache value</typeparam>
        /// <param name="value">Dictionary of key/value cache items</param>
        /// <param name="expirationMinutes">Expiration in minutes</param>
        public void SetAll <T>(IDictionary <string, T> value, int?expirationMinutes = null)
        {
            var timespan = TimeSpan.FromMinutes(expirationMinutes ?? _options.DefaultCacheMinutes);

            _easyCachingProvider.SetAll(value, timespan);
        }