Method GetByTag
GetByTag(Tag)
Gets all the cached objects with the specified tag.
Declaration
public virtual Hashtable GetByTag(Tag tag)
Parameters
Type | Name | Description |
---|---|---|
Tag | tag | The tag to search with. |
Returns
Type | Description |
---|---|
System.Collections.Hashtable | Returns a dictionary containing the cache keys and associated objects. |
Examples
The following example demonstrates how to get the objects with the specified tag.
Cache cache = NCache.InitializeCache("myCache");
Tag tag = new Tag("Sports");
Hashtable table = cache.GetByTag(tag);
GetByTag(String)
Gets all the cached objects with the specified tag.
Declaration
public virtual Hashtable GetByTag(string wildCardExpression)
Parameters
Type | Name | Description |
---|---|---|
System.String | wildCardExpression | The wild card Expression to search with. We provide two wildcard expressions i.e with '' and '?'. '' specifies that a word can be at the start or end of the expression where as '?' specifies missing character. Number of '?' specify the number of missing characters. |
Returns
Type | Description |
---|---|
System.Collections.Hashtable | Returns a dictionary containing the cache keys and associated objects. |
Examples
Suppose you have information of players in your cache who play different sports. You have added a tag with each player entry that contains contains information about what sport the play like "Sports:Cricket", "Sports:Basketball" etc. The following example demonstrates how to get information of all players:
Cache cache = NCache.InitializeCache("myCache");
Hashtable table = cache.GetByTag("Sports*"); //will return a dictionary containing information of all players.