How can I prevent outputcache ejection in code
the default asp.net in-memory cache mechanism ejects items from cache based on time. i want further control 开发者_Python百科to cancel ejection from cache under certain circumstances for certain objects. i tried rolling my own OutputCacheProvider but the Remove method is never called (so i can't implement logic there). it seems that the auto-ejection from the cache is done somewhere else. anyone know how i can tap into this?
The remove method would never be called as it is up to the provider to implement that functionality. There are a few cases were the Provider.Remove is called in the OutputCacheModule. Some custom providers I've seen check the expiration time (or other expire logic) in the Get method.
The default behavior is for output caching is to use the in memory provider. Normally would you hook a OnItemRemovedCallback when inserting the item into the HttpRuntime memory cache. In reality the HttpRuntime cache is evicting it by time so your custom provider code never gets evicted.
hth
精彩评论