Try Playground
Show / Hide Table of Contents

Method RemoveAsync

RemoveAsync<T>(String, WriteThruOptions)

Removes an item from the cache asynchronously, with a cache key to reference its location and WriteThruOptions.

Declaration
Task<T> RemoveAsync<T>(string key, WriteThruOptions writeThruOptions = null)
Parameters
Type Name Description
System.String key

Unique key of the item to be removed.

WriteThruOptions writeThruOptions

WriteThruOptions regarding updating the data source. This can be either WriteThru, WriteBehind or none.

Returns
Type Description
System.Threading.Tasks.Task<T>

Task that performs a remove operation in the background. Once completed returns the item that was removed from the cache. Task Status property can be used to determine status of the Task that can be IsCanceled, IsCompleted, and IsFaulted.

Type Parameters
Name Description
T

Specifies the type of value obtained from the cache.

Examples

The following example demonstrates how you can remove an item from your application's Alachisoft.NCache.Client.Cache object asynchronously.

ICache cache = CacheManager.GetCache("demoClusteredCache");

string key = "Product0";

WriteThruOptions writeThruOptions = new WriteThruOptions(WriteMode.WriteThru, "ProdDataSource1");

cache.RemoveAsync<Product>(key, writeThruOptions).ContinueWith(task => OnItemRemoved(key, task));

private static void OnItemRemoved(string key, Task<Product> task)
{
    if (task.Status == TaskStatus.RanToCompletion)
    {
    ...
    }
    if (task.Status == TaskStatus.Faulted)
    {
    ...
    }
    if (task.Exception != null)
    {
    ...
    }
}
In This Article
  • RemoveAsync<T>(String, WriteThruOptions)

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • 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 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top