tags:

views:

39

answers:

2

I am using the HttpRuntime cache to store lists of objects and in our current project it was specified that the objects should be cached until midnight, so I am using DateTime.Today.AddHours(24) in order to set the absolute expiration date to midnight.

For example, if today is May 26th, the absolute expiration time will be set to May 27th 0:00.

But somehow, when I change the clock of my computer, the objects are still in cache. Should I wait a little (the CacheItemPriority is set to Normal)? Am I forgetting something?

Thank you

+2  A: 

It does not guarantee that the cache will be expired at the exact time. There are conditions such as the system running low on memory that would cause the cache to expire. So don't assume that what you've put in the cache will be there later - always check first.

Darin Dimitrov
+2  A: 

ASP.NET can remove data from the cache for one of these reasons:

  • Because memory on the server is low, a process known as scavenging.

  • Because the item in the cache has
    expired.

  • Because the item's dependency
    changes.

  • To help you manage cached items,
    ASP.NET can notify your
    application when items are removed from the cache.

Pranay Rana