private void CacheItemRemove(string name, object obj1, CacheItemRemovedReason reason1)
 {
     try
     {
         CacheValue <TKey, TValue> value2 = (CacheValue <TKey, TValue>)obj1;
         if (reason1 != CacheItemRemovedReason.Removed)
         {
             base.Remove(value2.Key);
         }
         this.TryCacheItemRemove(value2.Key.Key);
         if (this.RemoveCallback != null)
         {
             this.RemoveCallback(value2.Key.Key, value2.Value);
         }
     }
     catch (ThreadAbortException)
     {
         throw;
     }
     catch (OutOfMemoryException)
     {
         throw;
     }
     catch (Exception exception)
     {
         SynchronizedCachedSingletonFactory <TKey, TValue> .logger.Error(exception);
     }
 }
        public override bool TryGet(CacheKey <TKey, TValue> key, out CacheValue <TKey, TValue> value)
        {
            object obj2 = this.cache[key.AspCacheKey];

            if (obj2 == null)
            {
                return(base.TryGet(key, out value));
            }
            value = (CacheValue <TKey, TValue>)obj2;
            return(true);
        }
        private bool Create(CacheKey <TKey, TValue> key, out CacheValue <TKey, TValue> value)
        {
            TValue local;

            if (this.DoCreateMethod(key.Key, out local))
            {
                value = new CacheValue <TKey, TValue>(key, local);
                return(true);
            }
            value = new CacheValue <TKey, TValue>();
            return(false);
        }
 protected abstract void InsertIntoCache(string key, CacheValue <TKey, TValue> instance, TimeSpan cacheTimeSpan, CacheItemRemovedCallback callback);
 protected override void DoAdd(CacheKey <TKey, TValue> key, CacheValue <TKey, TValue> value)
 {
     base.DoAdd(key, value);
     this.TryAdd(key.Key, key);
     this.InsertIntoCache(key.AspCacheKey, value, this.cacheTimeOut, new CacheItemRemovedCallback(this.CacheItemRemove));
 }
 /// <summary>
 /// Inserts an item into the asp net cache with absolute caching.
 /// </summary>
 /// <param name="key">The key. </param>
 /// <param name="instance">The instance.</param>
 /// <param name="cacheTimeSpan">The total time to keep the instance in cache.</param>
 /// <param name="callback">The remove callback.</param>
 protected override void InsertIntoCache(string key, CacheValue <TKey, TValue> instance, TimeSpan cacheTimeSpan, CacheItemRemovedCallback callback)
 {
     //base.Cache[key] instance, null, Add(cacheTimeSpan), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, callback);
 }
Пример #7
0
        public override bool Equals(object obj)
        {
            CacheValue <TKey, TValue> value2 = (CacheValue <TKey, TValue>)obj;

            return(this.Value.Equals(value2.Value));
        }