public static void Insert(string key, object keyValue, CacheDependency dep) { // Create the array of cache keys for the CacheDependency ctor string storageKey = GetHelperKeyName(key); string[] rgDepKeys = new string[1]; rgDepKeys[0] = storageKey; // Create a helper cache key HttpContext.Current.Cache.Insert(storageKey, dep); // Create a standard CacheDependency object System.Web.Caching.CacheDependency keyDep; keyDep = new System.Web.Caching.CacheDependency(null, rgDepKeys); // Create a new entry in the cache and make it dependent on a helper key HttpContext.Current.Cache.Insert(key, keyValue, keyDep); }
// ************************************************************************ // Modify the helper key thus breaking the dependency in the Cache protected virtual void NotifyDependencyChanged(CacheDependency dep) { string key = CacheHelper.GetHelperKeyName(DependentStorageKey); dep.UtcLastModified = DateTime.Now; HttpRuntime.Cache.Insert(key, dep); }