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,
 
Back
Top