Named Tags Properties and Usage Overview
This feature is only available in NCache Enterprise Edition.
Named Tags is a feature provided by NCache that is an enhanced form of Tags. They associate particular information with the items in the form of key-value pairs at runtime. In the case of tags, the keyword(s) associated with a cache item must be string-based identifiers. The advantage of named tags over tags is that they do not have this condition for the identifiers to hold a specific data type, whereas in tags and groups, the data type can only be a string.
Using named tags, the user can provide a name along with a value to bookmark a cache item, and they are independent of data types. Hence, the user is able to store additional information of any primitive type along with the cache item and use it later for further operations. Following is the list of supported primitive data types.
Tags and named tags provide high data relevance, making it easier for the user to access the data set based on the keyword(s). Moreover, by using tags or named tags, you can define indexes at runtime - improving performance and accessibility.
When to Use Named Tags
Let's suppose, there is a company having data of all customers, products, or orders in a large database. The attributes of products include ProductID, ProductName, or Category. The company has a flash sale on some items for a day that categorizes a particular set of data based on this discount. Instead of adding an attribute to the class and then removing that later, the user can add a Named Tag to those products which hold the discount.
This way, the user can append this information to the existing class of
Products at runtime; instead of adding a whole new attribute to the class. Considering the given scenario, the named tags added to the class
Product may have named tags where the name of the tag can be FlashSaleDiscount, and the value of this tag depicts that the product will have a 50% discount, so the value can be 0.5.
Following diagram depicts the whole scenario visually.
Here users are required to provide the list of named tags, each having two parameters, "key" (name of a tag) as a string and "value" (assigned value) as any primitive type. NCache then allows you to search your objects through these named tags.
Properties of Named Tags
Retrieve/Remove using Named Tags
These identifying marks can help you in finding and/or removing the items from the cache.
Support for Multiple Named Tags
You can add more than one key-value pairs in Named Tags with any cache item.
Like Tags, Named Tags provide a many-to-many grouping where one tag can contain multiple cached items and one cached item can belong to multiple tags.
Named Tags are case insensitive.
Querying Data using Named Tags
NCache supports Named Tags in queries.
Comparison Between Groups, Tags and Named Tags
Following table shows the comparison between the functionalities of groups, tags and Named Tags.
|Provided in the form of a dictionary||Provided in the form of an array of tags||Provided in the form of string|
|Can be of any primitive data type||String based only||String based only|