I would advise against using it. Your basically telling .NET to do
everything it can to keep the item in the cache. Of course, if the file
changes, that'll take priority. The priority only takes effect when none of
your other conditions are met (dependency, expiration time) but .NET needs
to free up some memory. It'll go through all the Cache item and purge them
based on priority until the needed amount of data is freed.
If you really don't want something to be removed, store it in the
Application object. But I'd only do that, or use NotRemovable when it was a
small piece of data that took a very very long time to get.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Michael" <hu**********@gmail.com> wrote in message
news:Oj*************@TK2MSFTNGP15.phx.gbl...
Hi,
I wrote the code to test how CacheItemPriority.NotRemovable works:
Cache.Insert("Time", DateTime.Now,
new System.Web.Caching.CacheDependency(Server.MapPath( "Test.txt")),
System.Web.Caching.Cache.NoAbsoluteExpiration,
System.Web.Caching.Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, null);
When then Test.txt is changed, the cache item "Time" is unavailable,
so CacheItemPriority.NotRemovable parameter is useless here?
How to use CacheItemPriority.NotRemovable and when should I use it?
Thanks!