NET Caching Library Help
GetSecondaryCacheKeys Method
Example 




KellermanSoftware.NetCachingLibrary Namespace > SmartCache Class : GetSecondaryCacheKeys Method
Get the keys for the secondary cache for a region
Syntax
'Declaration
 
Public Function GetSecondaryCacheKeys( _
   Optional ByVal regionName As System.String _
) As System.Collections.Generic.IEnumerable(Of String)
'Usage
 
Dim instance As SmartCache
Dim regionName As System.String
Dim value As System.Collections.Generic.IEnumerable(Of String)
 
value = instance.GetSecondaryCacheKeys(regionName)
public System.Collections.Generic.IEnumerable<string> GetSecondaryCacheKeys( 
   System.string regionName
)
public: System.Collections.Generic.IEnumerable<string*>* GetSecondaryCacheKeys( 
   System.string* regionName
) 
public:
System.Collections.Generic.IEnumerable<String^>^ GetSecondaryCacheKeys( 
   System.String^ regionName
) 

Parameters

regionName
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;
            
//Get the cache key based on the report parameters
string cacheKey = cache.BuildCacheKey("MonthlySalesReport", month, year);
            
//Get a long running report
List<ReportDetail> report = ReportLogic.MonthlySalesReport(month, year);
            
//Save to the cache
cache.Set<List<ReportDetail>>(cacheKey, report);
            
//Get all the keys in the file cache in the Default region
IEnumerable<string> keys = cache.GetSecondaryCacheKeys("Default");
            
foreach (var key in keys)
{
	Console.WriteLine(key);
}
'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
            
'Get the cache key based on the report parameters
Dim cacheKey As String = cache.BuildCacheKey("MonthlySalesReport", month, year)
            
'Get a long running report
Dim report As List(Of ReportDetail) = ReportLogic.MonthlySalesReport(month, year)
            
'Save to the cache
cache.Set(Of List(Of ReportDetail))(cacheKey, report)
            
'Get all the keys in the file cache in the Default region
Dim keys As IEnumerable(Of String) = cache.GetSecondaryCacheKeys("Default")
            
For Each key In keys
	Console.WriteLine(key)
Next key
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