Remove Object From Cache at Midnight

  • Thread starter Thread starter Jordan Richard
  • Start date Start date
J

Jordan Richard

What would be a good way to ensure that a DataTable, stored in the Cache,
gets removed from the Cache every day at midnight?

I know I can't assume that it's there - but if it is, I want it to be
removed at that particular time of day.

Thanks.
 
When you use the Insert method of the cache, you can specify an
absolute expiration as the 4th parameter.

ie:

DateTime midnight = DateTime.Now.AddDays(1).Date;
Cache.Insert("key", objectToCache, null, midnight, TimeSpan.Zero);

HTH,
 
Beautiful! Thanks. (don't know how I missed that in the documentation).
 

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

Back
Top