I want to permanently add an item to the cache. I am using the following syntax:
HttpContext.Current.Cache.Insert(cacheName, c, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration);
I have found out, that ASP.NET still sometimes removes items from the cache.
Any ideas on how to prevent this (in addition to dropping the cache and using Dictionary stored in a static member?
Matra
My answer is not correct. Please see here for a correct answer.
You can’t prevent ASP.NET from removing items from the cache (e.g. when memory gets low).
If you need to store data for the whole lifetime of the application, then put it into the ApplicationState collection, e.g:
This is similar to the SessionState collection, but as the name says, it’s application-wide.