Event if object is dropped out of the cache

S

Steffen Loringer

Hi All,

my application is storing some data from a file in the application
cache. The data in the cache is deleted if the original file is changed.
Because the point in time when this happens is unknown to me it would be
helpful to have an event etc. if this happens.
This should be used to load the modified data into the application
cache! Is there a good solution for this problem??

Thanks for your advice and hints

Steffen
 
K

Kevin Spencer

You don't need to know the point in time at which the object is removed. All
you need to know is that it is no longer there, which can be done by
checking to see if it is null.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
S

Steffen Loringer

And that moment I like to reload the data into the cache again. Without
any interaction. How can this be done?
 
G

Greg Burns

You can use a callback to run code when the cache expires.

Take a look at the overloaded method of Cahce.Insert that passes a delegate.

Not sure if the code run the instant the cache item expires, or when the
application next runs and "sees" that it expired...

HTH,
Greg
 
K

Kevin Spencer

And that moment I like to reload the data into the cache again. Without
any interaction. How can this be done?

If it isn't there, put it there. One way to do this is to use a Property
that returns the value from the Cache. The get method first checks to see if
the data is cached. If it is null, it refreshes the Cache, and then returns
the data. If not, it simply returns the data.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top