• Facebook
  • Twitter
  • Youtube
  • LinedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Download
  • Contact Us
Download
Show / Hide Table of Contents

Remove Data with Named Tags

The items added with Named Tags to the cache can also be removed from the cache using the same Named Tags. Additionally, like updating Named Tags, they can also be removed via CacheItem. This is a custom class provided by NCache which can be used to add data to the cache. To remove Named Tag via CacheItem, the Named Tag property of the CacheItem is set as null.

Prerequisites

  • .NET
  • Java
  • Python
  • Node.js
  • To learn about the standard prerequisites required to work with all NCache client-side features, please refer to the given page on Client-Side API Prerequisites.
  • For API details, refer to: ICache, CacheItem, NamedTags, GetCacheItem, Insert, Remove.
  • To learn about the standard prerequisites required to work with all NCache client-side features, please refer to the given page on Client-Side API Prerequisites.
  • For API details, refer to: Cache, CacheItem, NamedTagsDictionary, getCacheItem, insert.
  • To learn about the standard prerequisites required to work with all NCache client-side features, please refer to the given page on Client-Side API Prerequisites.
  • For API details, refer to: Cache, CacheItem, insert, get_cacheitem, set_named_tags, NamedTagsDictionary.
  • To learn about the standard prerequisites required to work with all NCache client-side features, please refer to the given page on Client-Side API Prerequisites.
  • For API details, refer to: Cache, CacheItem, NamedTagsDictionary, getCacheItem, insert, setNamedTags.

The following example removes the Named Tags via CacheItem:

  • .NET
  • Java
  • Python
  • Node.js
// Precondition: Cache is already connected

// A user wants to end the VIP membership discount offer
// So this Named Tag needs to be removed.

string customerKey = "Customer:ALFKI";

// Retrieve the CacheItem using the key
CacheItem cacheItem = cache.GetCacheItem(customerKey);

// Remove tag from dictionary
cacheItem.NamedTags.Remove("VIP_Membership_Discount");

// Reinsert the cacheItem in the cache with Named Tags removed
cache.Insert(customerKey, cacheItem);
// Precondition: Cache is already connected

// A user wants to end the VIP membership discount offer
// So this Named Tag needs to be removed.

String customerKey = "Customer:ALFKI";

// Retrieve the CacheItem using the key
CacheItem cacheItem = cache.getCacheItem(customerKey);

// Remove tag from dictionary
cacheItem.getNamedTags().remove("VIP_Membership_Discount");

// Reinsert the cacheItem in the cache with Named Tags removed
cache.insert(customerKey, cacheItem);
# Precondition: Cache is already connected

# A user wants to end the VIP membership discount offer
# So this Named Tag needs to be removed.

customer_key = "Customer:ALFKI"

# Retrieve the CacheItem using the key
cache_item = cache.get_cacheitem(customer_key)

# Set the Named Tags property of the cacheItem as null
cache_item.set_named_tags(None)

# Re-insert the cacheItem in the cache with Named Tags removed
cache.insert(customer_key, cache_item)
// This is an async method
// Precondition: Cache is already connected

// A user wants to end the VIP membership discount offer
// So this Named Tag needs to be removed.

var customerKey = "Customer:ALFKI";

// Retrieve the CacheItem using the key
var cacheItem = await this.cache.getCacheItem(customerKey);

// Set the Named Tags property of the cacheItem as null
cacheItem.setNamedTags(null);

// Reinsert the cacheItem in the cache with Named Tags removed
await this.cache.insert(customerKey, cacheItem);
Note

To ensure the operation is fail-safe, it is recommended to handle any potential exceptions within your application, as explained in Handling Failures.

Note

The cacheItem.NamedTags.Remove(tagName) method will remove the Named Tag associated with the tagName. If all Named Tags are removed from the Named Tags dictionary, it becomes empty. When the cache item is inserted into the cache with this empty dictionary, it will not retain any Named Tags.

Additional Resources

NCache provides a sample application for NamedTags on GitHub.

See also

.NET: Alachisoft.NCache.Runtime.Caching namespace.
Java: com.alachisoft.ncache.runtime.caching namespace.
Python: ncache.runtime.caching class.
Node.js: NamedTagsDictionary class.

Contact Us

PHONE

+1 214-619-2601   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top