internal static void ItemRemovedCallback(string key, object value, CacheItemRemovedReason reason) { if (reason == CacheItemRemovedReason.Expired) { CacheEntry cacheEntry = CacheLockbox.GetCacheEntry(key); if (cacheEntry.LastUse.Add(cacheEntry.SlidingExpiration) > DateTime.Now) { _cache.Insert(key, value, null, DateTime.Now.Add(TimeSpan.FromSeconds(30.0)), TimeSpan.Zero, CacheItemPriority.Low, null); ThreadPool.QueueUserWorkItem(delegate(object o) { string _key = o.ToString(); lock (CacheLockbox.GetInternalLock(_key)) { InternalCallback(_key); } }, key); } } }
internal static object InternalCallback(string key) { CacheEntry cacheEntry = CacheLockbox.GetCacheEntry(key); if (cacheEntry == null) { return(null); } CacheLoaderDelegate cacheLoader = cacheEntry.CacheLoader; if (cacheLoader == null) { return(null); } object obj2 = null; try { obj2 = cacheLoader(); } catch (Exception exception) { if (_cacheLoaderErrorDelegate != null) { try { _cacheLoaderErrorDelegate(key, exception); } catch { } } } if (obj2 != null) { Insert(key, obj2, null, (int)cacheEntry.RefreshInterval.TotalSeconds, CacheItemPriority.Normal, new CacheItemRemovedCallback(TCache.ItemRemovedCallback)); CacheLockbox.UpdateCacheEntry(key, DateTime.Now); } return(obj2); }