NamedCacheAsyncExtensionsInsertAsync Method (NamedCache, Byte, Object, Boolean, Boolean, CreatePolicy, CancellationToken)

ScaleOut Software NamedCache API
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which mimics the synchronous Insert(String, Object, CreatePolicy, Boolean, Boolean).

Namespace:  Soss.Client.Extensions
Assembly:  soss_namedcache (in soss_namedcache.dll) Version:

public static Task<AsyncPutResult> InsertAsync(
	this NamedCache cache,
	byte[] id,
	Object obj,
	bool updateIfExists,
	bool lockAfterInsert,
	CreatePolicy createPolicy = null,
	CancellationToken cancellationToken = null


Type: Soss.ClientNamedCache
the NamedCache this extension method operates on.
Type: SystemByte
a byte that will be transformed into a CachedObjectId via CreateKey(Byte) which identifies the object in the cache.
Type: SystemObject
Serializable object to store in the cache. The argument cannot be null.
Type: SystemBoolean
Determines behavior if the object already exists in the cache. If true, the object will be updated; if false, an ObjectExistsException will be thrown if the object already exists.
Type: SystemBoolean
If true, StateServer will atomically create and lock the object so that additional updates may be performed under a StateServer lock. If false, StateServer will create/update the object but leave it unlocked, allowing other clients to lock the object. NOTE:lockAfterInsert must be false if updateIfExists is true.
createPolicy (Optional)
Type: Soss.ClientCreatePolicy
A CreatePolicy instance containing extended cache policy information for the object. In this extension method, if the optional createPolicy parameter is null the DefaultCreatePolicy for cache is used instead.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
An optional CancellationToken that can be used to cancel the asynchronous operation.

Return Value

Type: TaskAsyncPutResult
a Task-wrapped AsyncPutResult which returns an indication as to whether the object was created or updated and any lockTicket resulting from a lock operation.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type NamedCache. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

ArgumentNullException when id null.

The specific combination of parameters where updateIfExists == true and lockAfterInsert == true is not supported in this wrapper. Instead, use PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) with appropriate PutOptions specified (and perhaps a valid LockTicket).
See Also