Cache and Sliding Expiration

Discussion in 'ASP .Net' started by Guadala Harry, Nov 4, 2004.

  1. AFAIK, when placing an object into the Cache with no special instructions
    (no dependencies, sliding expirations, hard expirations, etc), it will just
    sit there in the Cache until the system decides it needs to remove the
    object to free up memory. (If my understanding so far is wrong, please

    What I'd like to know is that if I place an object into the Cache with a
    sliding expiration - is it possible/likely that the system will remove the
    object prior to the expiration time being reached? Put another way, does a
    sliding expiration *only* instruct the system to remove the object at a
    certain time (at the end of the sliding window when eventually reached) -
    but otherwise allows the object to be removed from the Cache to free up
    resources if necessary prior to the end of the sliding window being reached?

    My code doesn't make any assumptions either way about an object being in the
    Cache at any given point in time - sliding window or not... I just want to
    understand the whole sliding window thing better.

    Guadala Harry, Nov 4, 2004
    1. Advertisements

  2. jongalloway

    jongalloway Guest

    The main thing about the sliding window is that it's reset every time
    the cache is accessed. So if you add something to the cache with a
    sliding timescale of 60 minutes and someone browses to the page every
    55 minutes, the cache will never be expired. Sliding expiration doesn't
    instruct the system to remove the object at a certain time - to do
    that, use an Absolute Expiration set in the future:
    Cache.Insert ("bigDataset", ds, null, DateTime.Now.AddMinutes (10),

    As for whether or not the object will be removed from the Cache,
    there's no way of knowing. Memory intensive objects are likely to be
    removed when memory is tight on the server, which means that another
    application's memory use could cause your application's cache to be
    cleaned more aggressively.

    You can also set the CacheItemPriority (CacheItemPriority.AboveNormal,
    for instance) to give further hints on how you'd like your cache

    As you indicated, you always have to assume your cache may have been
    cleared every time you access it.
    - Jon
    jongalloway, Nov 4, 2004
    1. Advertisements

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. Natty Gur
    John McDowell
    Aug 7, 2003
  2. Jeff
    Teemu Keiski
    Apr 23, 2004
  3. Dicky Cheng

    absolute expiration doesn't expire cache

    Dicky Cheng, Aug 13, 2004, in forum: ASP .Net
    Dicky Cheng
    Aug 16, 2004
  4. Steffen Loringer

    Cache expiration

    Steffen Loringer, Oct 14, 2004, in forum: ASP .Net
    Hans Kesting
    Oct 14, 2004
  5. Jeremy S.
    Brock Allen
    Mar 28, 2005

Share This Page