Default Cache Duration

J

Jordan S.

Using .NET 3.5... When I add an item to the system Cache, like this:

HttpRuntime.Cache["someString"] = "Some string";

For how long will it remain in the Cache by default. Could it remain there,
theoretically, forever?

I do understand that the system can purge items from the Cache at any time,
and that I have options to set absolute and sliding expirations as well as
cache item priority. But what happens if I explicitly set NONE of those
things? Does ASP.NET provide the entry with a default absolute expiration of
say Y minutes, or a default sliding expiration of X minutes? Or is it "just
there" with no absolute or sliding expiration, and will remain in the Cache
until the system decides to purge it which, for all we know could be 1
minute or 18 hours, for example, later?

Thanks.
 
M

Michael Nemtsev [MVP]

Hello Jordan S.,

There is no expire time by default, because when u use [] it insert your
data with the next properties
NoAbsoluteExpiration, NoSlidingExpiration, CacheItemPriority.Normal

What it means that lifetime of your value will be controled by asp.net runtime

Read it there http://msdn.microsoft.com/en-us/library/system.web.caching.cache.add.aspx


---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


J> Using .NET 3.5... When I add an item to the system Cache, like this:
J>
J> HttpRuntime.Cache["someString"] = "Some string";
J>
J> For how long will it remain in the Cache by default. Could it remain
J> there, theoretically, forever?
J>
J> I do understand that the system can purge items from the Cache at any
J> time, and that I have options to set absolute and sliding expirations
J> as well as cache item priority. But what happens if I explicitly set
J> NONE of those things? Does ASP.NET provide the entry with a default
J> absolute expiration of say Y minutes, or a default sliding expiration
J> of X minutes? Or is it "just there" with no absolute or sliding
J> expiration, and will remain in the Cache until the system decides to
J> purge it which, for all we know could be 1 minute or 18 hours, for
J> example, later?
J>
J> Thanks.
J>
 
M

Michael Nemtsev [MVP]

Hello Jordan S.,

I'd like to highlight my previous post that your cache item wont live forever
if you are inserted it via [].
Because CacheItemPriority is Normal in this case.

To keep your item forever (and die when app is going down) u need to set
the CacheItemPriority.NotRemovable priority

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


J> Using .NET 3.5... When I add an item to the system Cache, like this:
J>
J> HttpRuntime.Cache["someString"] = "Some string";
J>
J> For how long will it remain in the Cache by default. Could it remain
J> there, theoretically, forever?
J>
J> I do understand that the system can purge items from the Cache at any
J> time, and that I have options to set absolute and sliding expirations
J> as well as cache item priority. But what happens if I explicitly set
J> NONE of those things? Does ASP.NET provide the entry with a default
J> absolute expiration of say Y minutes, or a default sliding expiration
J> of X minutes? Or is it "just there" with no absolute or sliding
J> expiration, and will remain in the Cache until the system decides to
J> purge it which, for all we know could be 1 minute or 18 hours, for
J> example, later?
J>
J> Thanks.
J>
 
J

Jordan S.

Thank you Michael. The information you provided was what I could not find...
so that was helpful.

I had read the article at the link you provided as well as a bunch of
others. They all explain how to set specific expirations or sliding ones, as
well as cache item priorities. But that's not what I was wondering. I wanted
to know what happens by default when specifying NONE of those things. I
found it surprising that none of the documentation (that I found, anyway)
explained that. So thanks for providing that info (NoAbsoluteExpiration,
NoSlidingExpiration, CacheItemPriority.Normal).

-J
 
M

Michael Nemtsev [MVP]

Hello Jordan S.,

You can use Reflector to get this info

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


J> Thank you Michael. The information you provided was what I could not
J> find... so that was helpful.
J>
J> I had read the article at the link you provided as well as a bunch of
J> others. They all explain how to set specific expirations or sliding
J> ones, as well as cache item priorities. But that's not what I was
J> wondering. I wanted to know what happens by default when specifying
J> NONE of those things. I found it surprising that none of the
J> documentation (that I found, anyway) explained that. So thanks for
J> providing that info (NoAbsoluteExpiration, NoSlidingExpiration,
J> CacheItemPriority.Normal).
J>
J> -J
J>
J> J>
Hello Jordan S.,

There is no expire time by default, because when u use [] it insert
your
data with the next properties
NoAbsoluteExpiration, NoSlidingExpiration, CacheItemPriority.Normal
What it means that lifetime of your value will be controled by
asp.net runtime

Read it there
http://msdn.microsoft.com/en-us/library/system.web.caching.cache.add.
aspx

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we
miss it, but that it is too low and we reach it" (c) Michelangelo
J> Using .NET 3.5... When I add an item to the system Cache, like
this:
J> J> HttpRuntime.Cache["someString"] = "Some string";
J> J> For how long will it remain in the Cache by default. Could it
remain
J> there, theoretically, forever?
J> J> I do understand that the system can purge items from the Cache
at
any
J> time, and that I have options to set absolute and sliding
expirations
J> as well as cache item priority. But what happens if I explicitly
set
J> NONE of those things? Does ASP.NET provide the entry with a
default
J> absolute expiration of say Y minutes, or a default sliding
expiration
J> of X minutes? Or is it "just there" with no absolute or sliding
J> expiration, and will remain in the Cache until the system decides
to
J> purge it which, for all we know could be 1 minute or 18 hours, for
J> example, later?
J> J> Thanks.
J>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top