//Create a Primary Memory Cache with a backing File Cache
string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests");
SmartConfig config = new SmartConfig(new MemoryCacheProvider(), new FileCacheProvider(directory));
//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);
//Build parameters for the report
int month = DateTime.Now.Month;
int year = DateTime.Now.Year;
//Load the report from the database
List<ReportDetail> report = ReportLogic.MonthlySalesReport(month, year);
//Get the cache key based on the report parameters
string cacheKey = cache.BuildCacheKey("MonthlySalesReport", month, year);
SmartParms parms = new SmartParms(cacheKey, "Default",
DateTimeOffset.Now.AddMinutes(20),
DateTimeOffset.Now.AddMinutes(60 * 24));
List<ReportDetail> result = cache.AddOrGetExisting<List<ReportDetail>>(parms, report);
if (result == null)
Console.WriteLine("The item was added to the cache");
else
Console.WriteLine("The item already exists in the cache");