Named Tags in Data Caching: Overview
Named Tags is a feature provided by NCache that is an enhanced form of Tags for efficient data caching and retrieval. 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.
Note
This feature is only available in NCache Enterprise.
By using Named Tags in data caching, 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 can store additional information of any primitive type along with the cache item and use it later for further operations. The following is the list of supported primitive data types.
int
long
float
double
char
string
decimal
bool
DateTime
Tags and Named Tags provide high data relevance, ensure efficient data caching, and makes 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 in Data Caching
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 that 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.
The 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 pair in Named Tags with any cache item.
Many-to-Many Grouping
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.
Case Sensitive
Named Tags are case-insensitive.
Querying Data using Named Tags
NCache supports Named Tags in queries.
Comparison Between Groups, Tags, and Named Tags
The following table shows the comparison between the functionalities of Groups, Tags, and Named Tags.
Named Tags | Tags | Groups |
---|---|---|
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. |
See Also
Add/Update Cache Data with Named Tags
SQL Query with NamedTags
SQL Delete with NamedTags
Data Expiration
Tag Cache Data