To receive notification when a cached item is removed from the cache.we have CacheItemRemovedCallback.
public static void LoadCache(String pKey, Object obj) { HttpContext.Current.Cache.Insert(pKey, obj, null, DateTime.Now.AddMinutes(30), Cache.NoSlidingExpiration, CacheItemPriority.Normal, new CacheItemRemovedCallback(RemovedCallback)); }
public static void RemovedCallback(String k, Object v, CacheItemRemovedReason r) { HttpContext.Current.Response.Write("Key:"+k+" "); HttpContext.Current.Response.Write("Object:"+v.ToString()+" ") HttpContext.Current.Response.Write("Reason:"+r) }
|
| Author: chaithanya 11 Jun 2008 | Member Level: Silver Points : 1 |
Nice Post,its really useful for me in learning about Caching.
|