• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Try Free
Show / Hide Table of Contents

Method GetKeysByTag

GetKeysByTag(Tag)

Gets all keys of the objects with the specified tag.

Declaration
ICollection<string> GetKeysByTag(Tag tag)
Parameters
Type Name Description
Tag tag

The tag to search the cache with.

Returns
Type Description
System.Collections.Generic.ICollection<System.String>

Returns collection containing the cache keys.

Examples

The following example demonstrates how to get the keys with the specified tag.

ICache cache = CacheManager.GetCache("demoCache");
Tag tag = new Tag("Sports");
ICollection<string> keys = cache.SearchService.GetKeysByTag(tag);

GetKeysByTag(String)

Gets all the keys with the wild card supported tag.

Declaration
ICollection<string> GetKeysByTag(string wildCardExpression)
Parameters
Type Name Description
System.String wildCardExpression

The wild card Expression to search with.

Returns
Type Description
System.Collections.Generic.ICollection<System.String>

Returns collection containing the cache keys.

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 keys 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");

ICollection<string> keys = cache.SearchService.GetKeysByTag("*Customers");
Back to top Copyright © 2017 Alachisoft