Callback when cache expires in asp.net

Does anyone know a tutorial or an example of how I can run a function in asp.net when the cache expires? I read about the callback that runs when the cache expires, but I have not found any examples. I need this for a website. He must fulfill the function at the exact hour every day.

+2
source share
2 answers

hhh3112,

You can use the callback when the cache expires. you can explain a little more. I am not sure what you mean by a process that should be run at a specific hour every day.

string test = "test1";
Cache.Insert("Key", test, dependancy, DateTime.Now.AddMinutes(DateTime.Now), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, new CacheItemRemovedCallback(CacheRemovedCallback));

public string CacheRemovedCallback(String key, object value, System.Web.Caching.CacheItemRemovedReason removedReason)
{
    //Do something here
    return  = "Cache Expired for : " + key;
}
+3
source

All Articles