How clear App Fabric Cache one time a day?

401 Views Asked by At

I look for a configuration for clear cache each day at midnight.

It is possible ?

Or I need create a schedule task and clear in a code ?

1

There are 1 best solutions below

0
On
// My cache, handle it the way you like
private static DataCache _cache;

public static void ClearCache()
{
    Parallel.ForEach(_cache.GetSystemRegions(), region =>
    {
         _cache.ClearRegion(region);
         var sysRegion = _cache.GetSystemRegionName(region);
         _cache.ClearRegion(sysRegion);
     });
 }

Then run this at some schedule which you define yourself, somewhere.

I suppose the equivalent is fully possible to do in Powershell too, but this is a solution I've been using for a while.