Clear an item if the cache key matches a wildcard pattern for the specified region
Syntax
'Declaration
Public Sub ClearByWildCard( _
ByVal As System.String, _
Optional ByVal As System.String _
)
'Usage
Dim instance As SmartCache
Dim wildcardPattern As System.String
Dim region As System.String
instance.ClearByWildCard(wildcardPattern, region)
public void ClearByWildCard(
System.string ,
System.string
)
public: void ClearByWildCard(
System.string* ,
System.string*
)
public:
void ClearByWildCard(
System.String^ ,
System.String^
)
Parameters
- wildcardPattern
- region
Example
'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)
cache.Set(Of String)("LovelySpam", "WonderfulSpam")
cache.Set(Of String)("ChoppinBrocolli", "SheWasChoppinBrocolli")
cache.Set(Of String)("ChoppinBrocolliAtHome", "SheWasChoppinBrocolli")
'Clear any keys beginning with Choppin
cache.ClearByWildCard("Choppin*")
'These will both be false since both cache items were deleted
Console.WriteLine(cache.Contains("ChoppinBrocolli"))
Console.WriteLine(cache.Contains("ChoppinBrocolliAtHome"))
'This will be true since the key did not match the wildcard and the cache item still exists
Console.WriteLine(cache.Contains("LovelySpam"))
//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);
cache.Set<string>("LovelySpam", "WonderfulSpam");
cache.Set<string>("ChoppinBrocolli", "SheWasChoppinBrocolli");
cache.Set<string>("ChoppinBrocolliAtHome", "SheWasChoppinBrocolli");
//Clear any keys beginning with Choppin
cache.ClearByWildCard("Choppin*");
//These will both be false since both cache items were deleted
Console.WriteLine(cache.Contains("ChoppinBrocolli"));
Console.WriteLine(cache.Contains("ChoppinBrocolliAtHome"));
//This will be true since the key did not match the wildcard and the cache item still exists
Console.WriteLine(cache.Contains("LovelySpam"));
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