Remove Object From Cache at Midnight

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.
 
S

Scott Allen

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,
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top