Topics: Caching Application Block
Oct 29, 2007 at 5:19 PM
This might be a dumb question but how would you use a method that inherits from this interface? the ms-help example isn't exactly clear.

Let me see if I understand the workflow here:

1) You go to use a list of objects. Those objects aren't in the cache so you add them to the cache with an expiry policy.
2) The BackgroundScheduler starts based on its configured time and checks for expired cache items. Assuming an object in the cache has expired, the Background Scheduler marks the item as expired.
3) When the marking is done, the BackgroundScheduler checks if it can remove the marked items. Assuming you haven't accessed the cached object since it was marked, the item is removed from the cache.
4) The next time you go to use an object, if its not in the cache, you add it to the cache with an expiry policy... repeat over and over.

So, anybody care to offer an explanation on how you would use a method that inherits from this interface?

Oct 30, 2007 at 12:43 PM
Hi Roger,

This interface is more an expiration notification than an actual refresh action. There is some historical background about this in Len Fenster's "Effective Use of Microsoft Enterprise Library" book.

You can implement this interface to add the item back to the cache, but since the callback signature provides no context about the cache where the item used to belong, you will need to get this instance as part of your implementation of the interface (eg keeping it in a field).

So, after step 3 (and hopefully before step 4, but it cannot be guaranteed) the callback will run in a thread and add an updated version of the removed item back to the cache.

Hope this helps,