Inserts an object into the Cache asynchronously with dependencies, expiration and priority policies, and a delegate you can use to notify your application when the inserted item is removed from the Cache.

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 void InsertAsync(
	string key,
	Object value,
	AsyncItemUpdatedCallback onAsyncItemUpdateCallback,
	string group,
	string subGroup
)
Visual Basic
Public Sub InsertAsync ( _
	key As String, _
	value As Object, _
	onAsyncItemUpdateCallback As AsyncItemUpdatedCallback, _
	group As String, _
	subGroup As String _
)
Visual C++
public:
void InsertAsync(
	String^ key, 
	Object^ value, 
	AsyncItemUpdatedCallback^ onAsyncItemUpdateCallback, 
	String^ group, 
	String^ subGroup
)

Parameters

key
Type: System..::..String
The cache key used to reference the item.
value
Type: System..::..Object
The item to be added to the cache.
onAsyncItemUpdateCallback
Type: Alachisoft.NCache.Web.Caching..::..AsyncItemUpdatedCallback
A delegate that can be used to get the result of the Asynchronous update operation.
group
Type: System..::..String
An string that logically groups the data togehter.
subGroup
Type: System..::..String
The name of the subGroup within the group.

Remarks

This is similar to Insert(String, Object) except that the operation is performed asynchronously. A ItemUpdated 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 to insert an item into the cache asynchronously with associated group and subGroup. It also registers a delegate to get the result of the asynchronous operation. it into your application's Cache object.
CopyC#
Cache cache = NCache.InitializeCache("myCache");
cache.InsertAsync("DSN", connectionString, new AsyncItemUpdatedCallback(onAsyncItemUpdated), "group-name", "subGroup-name");

Exceptions

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

See Also