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.3.0.0 (4.3.0.0)

Syntax

C#
public virtual void InsertAsync(
	string key,
	Object value,
	AsyncItemUpdatedCallback onAsyncItemUpdateCallback,
	string group,
	string subGroup
)
Visual Basic
Public Overridable Sub InsertAsync ( 
	key As String,
	value As Object,
	onAsyncItemUpdateCallback As AsyncItemUpdatedCallback,
	group As String,
	subGroup As String
)
Visual C++
public:
virtual 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.
 Copy imageCopy
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