Method GetByTag
GetByTag<T>(Tag)
Gets all the cached items with the specified tag.
Declaration
IDictionary<string, T> GetByTag<T>(Tag tag)
Parameters
Type | Name | Description |
---|---|---|
Tag | tag | Name of tag to search the cache items with. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, T> | Returns a dictionary containing the cache keys and associated objects with the type specified. |
Type Parameters
Name | Description |
---|---|
T | Specifies the type of value obtained from the cache. |
Examples
The following example demonstrates how to get the objects with the specified tag.
ICache cache = CacheManager.GetCache("demoCache");
Tag tag = new Tag("Sports");
IDictionary<string,Product> result = cache.SearchService.GetByTag<Product>(tag);
GetByTag<T>(String)
Gets all the cached objects with the wild card supported tag.
Declaration
IDictionary<string, T> GetByTag<T>(string wildCardExpression)
Parameters
Type | Name | Description |
---|---|---|
System.String | wildCardExpression | The wild card Expression to search with. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, T> | Returns a dictionary containing the cache keys and associated objects with the type specified. |
Type Parameters
Name | Description |
---|---|
T | Specifies the type of value obtained from the cache. |
Remarks
The special characters supported in wild search by NCache are: 1) "*" : Used as a substitute for zero or more characters in the string. 2)"?" : Used as a substitute for a single character in the string.
Examples
The following example demonstrates how to get the objects with the specified tag using wildcard.
ICache cache = CacheManager.GetCache("demoCache");
Following tags are created and items are added in the cache with these tags
Tag[] tags = new Tag[3];
tags[0] = new Tag("Important Customers");
tags[1] = new Tag("East Coast Customers");
tags[2] = new Tag("West Coast Customers");
IDictionary<string, Customer> result = cache.SearchService.GetByTag<Customer>("*Customers");