Method RemoveAsync
RemoveAsync(String, AsyncItemRemovedCallback, DSWriteOption, DataSourceItemsRemovedCallback)
Declaration
[TargetMethod(1)]
public virtual void RemoveAsync(string key, AsyncItemRemovedCallback onAsyncItemRemoveCallback, DSWriteOption dsWriteOption, DataSourceItemsRemovedCallback onDataSourceItemRemovedCallback)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | |
AsyncItemRemovedCallback | onAsyncItemRemoveCallback | |
DSWriteOption | dsWriteOption | |
DataSourceItemsRemovedCallback | onDataSourceItemRemovedCallback |
RemoveAsync(String, AsyncItemRemovedCallback, DSWriteOption, String, DataSourceItemsRemovedCallback)
Removes the object from the Cache asynchronously.
Declaration
[TargetMethod(2)]
public virtual void RemoveAsync(string key, AsyncItemRemovedCallback onAsyncItemRemoveCallback, DSWriteOption dsWriteOption, string providerName, DataSourceItemsRemovedCallback onDataSourceItemRemovedCallback)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The cache key used to reference the item. |
AsyncItemRemovedCallback | onAsyncItemRemoveCallback | The delegate that can be used by the client application to get the result of the Asynchronous Remove operation. |
DSWriteOption | dsWriteOption | Options regarding updating data source |
System.String | providerName | WriteThru provider name |
DataSourceItemsRemovedCallback | onDataSourceItemRemovedCallback | A delegate that, if provided, is called when item is removed from data source. |
Remarks
This is similar to Remove(String) except that the operation is performed asynchronously. A ItemRemoved event is fired upon successful completion of this method.It is not possible to determine if the actual operation has failed, therefore use this operation for the cases when it does not matter much.
Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception incase of failure.
Examples
The following example demonstrates how you can remove an item from your application's Cache object.
OnAsyncItemRemoved(string key, object result)
{
...
}
OnDataSourceItemsRemoved(IDictionary result)
{
...
}
Cache cache = NCache.InitializeCache("myCache");
cache.RemoveAsync("timestamp", DSWriteOption.WriteBehind, new AsyncItemRemovedCallback(OnAsyncItemRemoved), new DataSourceItemsRemovedCallback(OnDataSourceItemsRemoved), "group-name", "subGroup-name");
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException |
|