//Create a file cache with async set and remove
string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests");
FileCacheProvider fileCacheProvider = new FileCacheProvider(directory);
fileCacheProvider.IsAsyncSetAndRemove = true;
SmartConfig config = new SmartConfig(new MemoryCacheProvider(), fileCacheProvider);
//Specify UserName and LicenseKey for Licensed Mode
//config.UserName = "my user name";
//config.LicenseKey = "my license key";
//Instantiate the cache
SmartCache cache = new SmartCache(config);
//Save 12 months asynchronously
for(int i = 1; i <= 12;i++)
{
string cacheKey = string.Format("FlushTest-{0}", i);
//Get a long running report
List<ReportDetail> report = ReportLogic.MonthlySalesReport(i, DateTime.Now.Year - 1);
//Save to the cache asynchronously
cache.Set<List<ReportDetail>>(cacheKey, report);
}
//Flush the cache
cache.Flush(5);
//This will be false since we flushed
Console.WriteLine(cache.IsBusy);