|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How and when should I use CacheItemPriority.NotRemovable?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! 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 -- Show quoteHide quoteMY ASP.Net tutorials http://www.openmymind.net/ http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX! "Michael" <huanlin.t***@gmail.com> wrote in message news:OjO71Hk8FHA.132@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! > Hi Karl,
Got it! Thank you very much :) Show quoteHide quote >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.
Other interesting topics
TreeView problem
Deploying ASP.NET 2.0 Odd behavior in 2005 with base page classes Accessing session from thread how to parse deeper nested tags in custom control ## in ASP.NET 2.0 Forms authentication with images on the login page Problem migrating Web Project from ASP.Net 1.1 to 2.0 Rols/rights in asp 2.0 Open and read/write ASPX file |
|||||||||||||||||||||||