public static bool Update(string key) { if (!CacheLockbox.ContainsCacheEntry(key)) { return(false); } lock (CacheLockbox.GetInternalLock(key)) { InternalCallback(key); } return(true); }
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); } } }
public static void RefreshByPattern(string pattern) { ThreadPool.QueueUserWorkItem(delegate(object _pattern) { IEnumerator <string> enumerator = CacheLockbox.Keys.GetEnumerator(); Regex regex = new Regex(_pattern.ToString(), RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase); while (enumerator.MoveNext()) { string current = enumerator.Current; if (regex.IsMatch(current)) { lock (CacheLockbox.GetInternalLock(current)) { InternalCallback(current); continue; } } } }, pattern); }