Removes the object from the Cache asynchronously.

Namespace: Alachisoft.NCache.Web.Caching
Assembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: 4.1.0.0 (4.1.0.0)

Syntax

C#
public virtual void RemoveAsync(
	string key,
	AsyncItemRemovedCallback onAsyncItemRemoveCallback,
	DSWriteOption dsWriteOption,
	string providerName,
	DataSourceItemsRemovedCallback onDataSourceItemRemovedCallback
)
Visual Basic
Public Overridable Sub RemoveAsync ( _
	key As String, _
	onAsyncItemRemoveCallback As AsyncItemRemovedCallback, _
	dsWriteOption As DSWriteOption, _
	providerName As String, _
	onDataSourceItemRemovedCallback As DataSourceItemsRemovedCallback _
)
Visual C++
public:
virtual void RemoveAsync(
	String^ key, 
	AsyncItemRemovedCallback^ onAsyncItemRemoveCallback, 
	DSWriteOption dsWriteOption, 
	String^ providerName, 
	DataSourceItemsRemovedCallback^ onDataSourceItemRemovedCallback
)

Parameters

key
Type: System..::..String
The cache key used to reference the item.
onAsyncItemRemoveCallback
Type: Alachisoft.NCache.Web.Caching..::..AsyncItemRemovedCallback
The delegate that can be used by the client application to get the result of the Asynchronous Remove operation.
dsWriteOption
Type: Alachisoft.NCache.Web.Caching..::..DSWriteOption
Options regarding updating data source
providerName
Type: System..::..String
WriteThru provider name
onDataSourceItemRemovedCallback
Type: Alachisoft.NCache.Web.Caching..::..DataSourceItemsRemovedCallback
A delegate that, if provided, is called when item is removed from data source.

Return Value

The item removed from the Cache. If the value in the key parameter is not found, returns a null reference (Nothing in Visual Basic).

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.
CopyC#
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

ExceptionCondition
System..::..ArgumentNullExceptionkey contains a null reference (Nothing in Visual Basic).
System..::..ArgumentExceptionkey is not serializable.

See Also