Expiration cache absolute object - can it be manually deleted?

has been pulling my hair for this for the past few hours.

I have a cache object.

HttpRuntime.Cache.Insert("Members", AllMembersList, null, DateTime.Now.AddHours(1), TimeSpan.Zero);

      

when i try to clear the cache object.

HttpRuntime.Cache.Remove("Members");

      

its value doesn't change, until 1 hour or when I reset the server.

My question .. for a cache object set to an absolute expiration, can I delete it manually or will it exist for a full hour?

I would like this object to last for an hour, but depending on the execution of the program, I could clean it up so that it contains fresh data.

any help is most appreciated

truegilly

+2


a source to share


2 answers


The method Remove

should work fine for this.

Are you sure you are calling correctly Remove

and that there is no other code re-inserting the item into the cache?



+1


a source


From http://www.neovolve.com/page/Cache-Expiration-Policies.aspx

When are items actually flushed from the cache?

Most of the basics of caching will remove expired items from the cache when system resources are low or when the cache is being referenced. This means that a cache entry that has an absolute or sliding expiration date cannot be removed from the cache until some future time, which may well be after the entry has expired.

This is for performance reasons. caching systems typically use a purge algorithm that looks for expired records and removes them. This is usually called when the cache is referenced, not when the items actually expire. This allows the cache to avoid having to constantly monitor for time-based events to know when to remove items from the cache.



You can try setting the cached value to null.

+1


a source







All Articles