.NET 4 ObjectCache - Can We Hook Into a “Cache Expired” Event?

前端 未结 3 1979
轮回少年
轮回少年 2021-02-12 23:47

I\'ve got a simple object being cached like this:

_myCache.Add(someKey, someObj, policy);

Where _myCache is declared as Obje

3条回答
  •  伪装坚强ぢ
    2021-02-13 00:36

    There's a property on the CacheItemPolicy called RemovedCallback which is of type: CacheEntryRemovedCallback. Not sure why they didn't go the standard event route, but that should do what you need.

    http://msdn.microsoft.com/en-us/library/system.runtime.caching.cacheitempolicy.removedcallback.aspx

提交回复
热议问题