Inject Caching Callback Function

Topics: Policy Injection Application Block
Aug 11, 2007 at 2:15 PM

I may be wrong but I believe the Policy Injection Block could be used to intercept a call to the Caching Block when a new item is being added to the cache. By intercepting the call, all I want to do is specify a default callback function (for when the cached item expires) for all items added to the cache. So, program code tries to add a new item to the cache, the policy injection block intercepts the call and tells the caching block the name of my default callback handler for expired items.

Assuming this can be done, can anyone give me any guidelines on how to achieve this? I don't have much experience with the Enterprise Library.

Thanks in advance,

Aug 13, 2007 at 3:53 PM

Unfortunately the classes that implement the Caching Block don't meet the requirements to be intercepted using the default mechanism; please see topic "Deciding if an Object is Interceptable" from the integrated help. These classes do not inherit from MBRO, and although class Cache implements ICacheOperations the reference from class CacheManager is to the class, not the interface.

If you want to make this work you'll need to write and/or change the existing code.