NET Caching Library Help
ClearRegion Method (SmartCache)
Example 




KellermanSoftware.NetCachingLibrary Namespace > SmartCache Class : ClearRegion Method
Name of the region
Clear everything for the specified region
Syntax
'Declaration
 
Public Sub ClearRegion( _
   Optional ByVal regionName As System.String _
) 
'Usage
 
Dim instance As SmartCache
Dim regionName As System.String
 
instance.ClearRegion(regionName)
public void ClearRegion( 
   System.string regionName
)
public: void ClearRegion( 
   System.string* regionName
) 
public:
void ClearRegion( 
   System.String^ regionName
) 

Parameters

regionName
Name of the region
Example
//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);
            
//Save the report to the cache to the Default Region
cache.Set(cacheKey, report, "Default");
            
//Save the report to the cache to the Other Region
cache.Set(cacheKey, report, "Other");
            
//Clear the default region
cache.ClearRegion("Default");
            
//Primary Count Will Be Zero for Default region
Console.WriteLine(cache.GetPrimaryCount("Default"));
            
//Primary Count Will Be One or more for the 
Console.WriteLine(cache.GetPrimaryCount("Other"));
'Create a Primary Memory Cache with a backing File Cache
Dim directory As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests")
Dim config As 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
Dim cache As New SmartCache(config)
            
'Build parameters for the report
Dim month As Integer = Date.Now.Month
Dim year As Integer = Date.Now.Year
            
'Load the report from the database
Dim report As List(Of ReportDetail) = ReportLogic.MonthlySalesReport(month, year)
            
'Get the cache key based on the report parameters
Dim cacheKey As String = cache.BuildCacheKey("MonthlySalesReport", month, year)
            
'Save the report to the cache to the Default Region
cache.Set(cacheKey, report, "Default")
            
'Save the report to the cache to the Other Region
cache.Set(cacheKey, report, "Other")
            
'Clear the default region
cache.ClearRegion("Default")
            
'Primary Count Will Be Zero for Default region
Console.WriteLine(cache.GetPrimaryCount("Default"))
            
'Primary Count Will Be One or more for the 
Console.WriteLine(cache.GetPrimaryCount("Other"))
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

SmartCache Class
SmartCache Members