CacheItemPriority.NotRemovable -- When will the item get removed?

Topics: Caching Application Block
Sep 11, 2012 at 2:47 PM

I am having a few application configuration variables that I would like to load in the Cache. I would like to qualify it as 

CacheItemPriority.NotRemovable

However, I am concerned when it would scavenge or should I manually write a code for it? Will it get removed on IISReset?

Sep 11, 2012 at 11:57 PM

If you add an item to the cache with a CacheItemPriority of NotRemovable then that item will not be eligible for scavenging.  You could manually remove the item whenever you wish using the Remove() method.

If you are using an in-memory cache (NullBackingStore) then the lifetime of the CacheItem will be the lifetime of the AppDomain.  An IISReset will restart the web server and tear down the AppDomain (and the cache).

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Sep 12, 2012 at 12:39 AM
Wonderful.

Thanks Randy Levy. I am using a few application wide settings and hence I would prefer caching these settings as long as the application runs. It is enough if the cache is cleared when IIS is reset.

Thanks and Regards,

----
Deepak Kumar Vasudevan



From: [email removed]
To: [email removed]
Date: Tue, 11 Sep 2012 16:57:29 -0700
Subject: Re: CacheItemPriority.NotRemovable -- When will the item get removed? [entlib:395130]

From: randylevy
If you add an item to the cache with a CacheItemPriority of NotRemovable then that item will not be eligible for scavenging. You could manually remove the item whenever you wish using the Remove() method.
If you are using an in-memory cache (NullBackingStore) then the lifetime of the CacheItem will be the lifetime of the AppDomain. An IISReset will restart the web server and tear down the AppDomain (and the cache).
--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com