The tables and stored procedures will be automatically created in the database when the Setup command is executed or when the first item is loaded or saved to the cache.
//** Example setup of SQL Server Provider
OracleCacheProvider oracleProvider = new
OracleCacheProvider();
sqlProvider.ConnectionString = "
@"Data Source=XE;User Id=system;Password=password;";
oracleProvider.MaxCacheItems = 1000;
oracleProvider.MaxMegabytes = 100;
oracleProvider.Encrypt = true;
oracleProvider.EncryptionKey = "secret";
oracleProvider.UseStoredProcedures = true;
oracleProvider.Setup();
//Attach the oracle server provider as the secondary storage
SmartCache.Storage = oracleProvider;
//** Example Load and Save
//Build parameters for the report
int month = DateTime .Now.Month;
int year = DateTime .Now.Year;
//Get the cache key based on the report parameters
//The get cache key method uses reflection to ensure uniqueness
string cacheKey = SmartCache .GetCacheKey(month, year);
//Attempt to load the report from the cache
List < ReportDetail > report = SmartCache .Load< List < ReportDetail >>(cacheKey);
//Not found in the cache
if (report == null )
{
//Load the report from the database
report = ReportLogic .MonthlySalesReport(month, year);
//Save to the cache using the default expiration type and default expiration minutes
SmartCache .Save< List < ReportDetail >>(cacheKey, report);
}