コード例 #1
0
 public void Set(string cacheKey, object value)
 {
     lock (CacheLock)
     {
         InnerCache.Add(cacheKey, value);
     }
 }
コード例 #2
0
        public void Add(string cacheKey, TimeSpan slidingExpiryWindow, object dataToAdd)
        {
            if (dataToAdd == null || !IsCacheEnabled)
            {
                return;
            }

            InnerCache.Add(cacheKey, slidingExpiryWindow, dataToAdd);
        }
コード例 #3
0
        public void Add(string cacheKey, DateTime absoluteExpiryDate, object dataToAdd)
        {
            if (dataToAdd == null || !IsCacheEnabled)
            {
                return;
            }

            InnerCache.Add(cacheKey, absoluteExpiryDate, dataToAdd);
        }
コード例 #4
0
 public virtual void Add(string ip, WhoIsInformation value)
 {
     Assert.ArgumentNotNull(ip, "ip");
     Assert.ArgumentNotNull(value, "value");
     if (!Enabled)
     {
         return;
     }
     InnerCache.Add(ip, value, Settings.GeoIpCacheExpiryTime);
 }
コード例 #5
0
        //AddSite
        public void AddSite(Site siteItem)
        {
            if (ContainsSite(siteItem))
            {
                RemoveSite(siteItem);
            }

            var cacheItem = new SiteCacheItem(siteItem);

            InnerCache.Add(siteItem.Name, cacheItem);
        }
コード例 #6
0
        /// <summary>
        ///     Adds or updates the specified key/value pair.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <returns>
        ///     True if the specified key/value pair was added;
        ///     False if the specified key/value pair was updated.
        /// </returns>
        public bool Add(TKey key, TValue value)
        {
            bool added = InnerCache.Add(key, value);

            if (added)
            {
                IncrementCount();
                MetricReporter.NotifySizeChange(Name);
            }

            return(added);
        }
コード例 #7
0
        protected override void Add <TValue>(string key, TValue value)
        {
            var val = Newtonsoft.Json.JsonConvert.SerializeObject(
                value,
                Newtonsoft.Json.Formatting.None,
                new Newtonsoft.Json.JsonSerializerSettings
            {
                TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All,
                Culture          = System.Globalization.CultureInfo.InvariantCulture,
            });

            InnerCache.Add(key, val, GetRuntimePolicy(), null);
        }
コード例 #8
0
        /// <summary>
        ///     Adds or updates the specified key/value pair.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <returns>
        ///     True if the specified key/value pair was added;
        ///     False if the specified key/value pair was updated.
        /// </returns>
        public bool Add(TKey key, TValue value)
        {
            bool added = true;

            RedisKey redisKey = GetRedisKey(key);

            _memoryStore.StringSet(redisKey, GetRedisValue(key, value), KeyExpiry);

            if (InnerCache != null)
            {
                added = InnerCache.Add(key, value);
            }

            return(added);
        }
コード例 #9
0
        public void SetObject(string key, object value, long size, int lifespan)
        {
            if (value == null || InnerCache.MaxSize == 0)
            {
                return;
            }

            try
            {
                if (lifespan > 0)
                {
                    InnerCache.Add(key, value, size, TimeSpan.FromSeconds(lifespan));
                }
                else
                {
                    InnerCache.Add(key, value, size);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Failed to set a cache object", ex, "SharedSource.RedirectModule.Caching");
            }
        }
コード例 #10
0
 /// <summary>
 /// Add new data to the cache
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public void AddData <T>(object key, object value)
 {
     InnerCache.Add(key, value, GetObjectCacheSize(value), CacheDuration);
 }
コード例 #11
0
 /// <summary>
 ///     Adds or updates the specified key/value pair.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 ///     True if the specified key/value pair was added;
 ///     False if the specified key/value pair was updated.
 /// </returns>
 public bool Add(TKey key, TValue value)
 {
     return(InnerCache.Add(key, value));
 }
コード例 #12
0
 public void SetRules <T>(IEnumerable <T> outboundRules, string key) where T : IBaseRule
 {
     InnerCache.Add(key, outboundRules);
 }