473,499 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!
Nov 26 '05 #1
2 5409
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!

Nov 26 '05 #2
Hi Karl,

Got it! Thank you very much :)
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.

Nov 26 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
19921
by: sql-db2-dba | last post by:
Does DB2 just fudge it when it is an empty table? Is there a "formula" for average row size when you have variable length records. Or you really have to know what your application is packing into...
4
5898
by: Peter Row | last post by:
Hi, I have created a UserControl which is subsequently hosted on a standard form. My control has a TabControl on it but it has no TabPages configured. At runtime I create X pages and put a...
5
555
by: AAguiar | last post by:
I have an asp.net project where the code behind the aspx page calls a c# class which makes calls to a managed static C++ class. The C# class works fine when the asp net worker process starts, when...
8
2540
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
3
3054
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
6
1748
by: Adam | last post by:
On an xp machine, the caching works as expected. I have deployed to a win2k server, and an item I add to the cache expires almost immediately some times and in under a minute in other times. The...
2
2407
by: mahesh.prasad | last post by:
Hi, I'm trying to add an object to the .NET cache using a CacheDependency and I get the following exception : System.InvalidOperationException: Cache_dependency_used_more_that_once at...
3
5404
by: mrutyunjaya | last post by:
if (Cache==null) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings.ConnectionString); SqlDataAdapter mydataadapter = new...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.