Esempio n. 1
0
        /// <summary>
        /// Inserts the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="dep">The dep.</param>
        /// <param name="timeframe">The timeframe.</param>
        /// <param name="priority">The priority.</param>
        public static void Insert(string key, object obj, CacheDependency dep, TimeSpan timeframe, CacheItemPriority priority)
        {
            CacheItemRemovedCallback callback = null;

            // only need call back if item is in the locking states
            if (CacheEntries.ContainsKey(key))
            {
                callback = new CacheItemRemovedCallback(CacheHelper.ItemRemovedCallback);
            }

            Insert(key, obj, dep, timeframe, priority, callback);
        }
Esempio n. 2
0
        /// <summary>
        /// Items the removed callback.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <param name="reason">The reason.</param>
        internal static void ItemRemovedCallback(string key, object value, CacheItemRemovedReason reason)
        {
            if (reason == CacheItemRemovedReason.Expired)
            {
                CacheEntry cacheEntry = CacheEntries.Get(key);

                if (cacheEntry != null)
                {
                    lock (cacheEntry.Lock)
                    {
                        CacheEntries.Remove(key);
                    }
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Gets the lock.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <returns></returns>
 public static object GetLock(string key)
 {
     return(CacheEntries.GetLock(key));
 }