Cache expiration

S

Steffen Loringer

Hi,

i like to store some data in the Cache on the server. The data should be
removed once a file on the server is changed (I'm using a
Cache.Dependency). Because the data should be reloaded into the Cache
I'm also using a callback method.
But I can't figure out, how to add the data without any time dependency.
I can't use
Cache.Insert("Test", test, cacheDependency, Nothing, Nothing,
Caching.CacheItemPriority.High, onCacheRemove) because this immediately
reloads the data.

The data should be removed if the file is changed - and only in that
case! Any ideas?

Thanks for help
Steffen
 
H

Hans Kesting

Steffen said:
Hi,

i like to store some data in the Cache on the server. The data should
be removed once a file on the server is changed (I'm using a
Cache.Dependency). Because the data should be reloaded into the Cache
I'm also using a callback method.
But I can't figure out, how to add the data without any time
dependency. I can't use
Cache.Insert("Test", test, cacheDependency, Nothing, Nothing,
Caching.CacheItemPriority.High, onCacheRemove) because this
immediately reloads the data.

The data should be removed if the file is changed - and only in that
case! Any ideas?

Thanks for help
Steffen

I personally don't use callbacks to reload data. When I store things in the Cache,
I usually have a method to retrieve it. This method checks if the item is cached.

If it is cached, return that.
If it isn't cached (file changed, never stored yet) then create the object, cache it
and return it.

For duration and time there are constants in System.Web.Caching.Cache:
NoAbsoluteExpiration and NoSlidingExpiration.

Hans Kesting
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top