What is Cache Callback ?

Cache Callback provides an ability where by some actions can be performed when that item is removed from cache

CacheItemRemovedCallback example


System.Web.Caching.CacheItemRemovedCallback callback = new System.Web.Caching.CacheItemRemovedCallback (OnRemove);

Cache.Insert("key",myFile,null,

System.Web.Caching.Cache.NoAbsoluteExpiration,

TimeSpan.Zero,

System.Web.Caching.CacheItemPriority.Default, callback);

. . .

public static void OnRemove(string key,

object cacheItem,

System.Web.Caching.CacheItemRemovedReason reason)

{

AppendLog("The cached value with key '" + key +

"' was removed from the cache. Reason: " +

reason.ToString());

}

No comments:

Popular Posts