Default Cache Duration

Discussion in 'ASP .Net' started by Jordan S., Jun 5, 2008.

  1. Jordan S.

    Jordan S. Guest

    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.
     
    Jordan S., Jun 5, 2008
    #1
    1. Advertising

  2. 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>
     
    Michael Nemtsev [MVP], Jun 5, 2008
    #2
    1. Advertising

  3. 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>
     
    Michael Nemtsev [MVP], Jun 5, 2008
    #3
  4. Jordan S.

    Jordan S. Guest

    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


    "Michael Nemtsev [MVP]" <> wrote in message
    news:...
    > 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>
    >
    >
     
    Jordan S., Jun 5, 2008
    #4
  5. 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> "Michael Nemtsev [MVP]" <> wrote in message
    J> news:...
    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>
     
    Michael Nemtsev [MVP], Jun 5, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    589
    Jeff Nokes
    Sep 30, 2003
  2. DesignerX

    Page.Cache vs HttpContext.Current.Cache

    DesignerX, Jan 20, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    8,292
    vMike
    Jan 20, 2004
  3. Thomas

    User control cache duration

    Thomas, Jul 22, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    686
    Thomas
    Jul 23, 2004
  4. Replies:
    1
    Views:
    298
    Victor Bazarov
    Jul 26, 2007
  5. Jordan S.

    System Cache - duration

    Jordan S., Jun 2, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    337
    Michael Nemtsev [MVP]
    Jun 2, 2008
Loading...

Share This Page