I wanted to know if there is any event which occurs each time a cache item is about too get expired or any event which is raised when a cache item is getting expired.I am using enterprise library in asp.net for caching.I want to store some data in my database when a cache is about to get expired instead of calling a function or invoking an event myself I was thinking of using the already managed cache library event which is being used to flush or dispose cache items.
Share
Assuming you’re using the Caching Application Block then you specify a callback delegate when you add items to the cache.
You need to supply a class implementing
ICacheItemRefreshAction:As you can see, when an item is removed, this
Refresh()method is called with the key and the object that’s being removed. You just need to cast theexpiredObjectparameter to the correct type and arrange to have it stored to the database.As documented here: http://msdn.microsoft.com/en-us/library/ff664621(v=PandP.50).aspx