Sometimes when working on my local machine, items that I put into the ASP.Net Cache would just seem to disappear immediately from the Cache, defeating the purpose of caching. When hooking in the "CacheItemRemovedCallBack" in the add method, the reason the items were removed from the Cache was "underused".
Basically I was running into the same issue described here. It seems like the Cache was working as expected, it just "thought" that I had not enough memory left to cache any items.
One solution that was suggested on the web is to "disableMemoryCollection" for the cache as described here.
I think that would be acceptable on a developer's machine for debugging, but not for a production server, because again, letting the Cache manage it's own memory seems the better approach here.
The other option is to add the items to the Cache with a "notRemovable" priority. That also seems like asking for trouble, because then ASP.Net is forced to keep stuff in the Cache even if that memory was better used for serving a spike in user requests for instance.
There are a few settings that control the ASP.Net Cache's policies on reclaiming space and purging items settings: http://forums.asp.net/thread/1199949.aspx
No comments:
Post a Comment