NamedCacheAsyncExtensionsInsertAsync Method (NamedCache, CachedObjectId, 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(CachedObjectId, Object, CreatePolicy, Boolean, Boolean).

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

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

Parameters

cache
Type: Soss.ClientNamedCache
the NamedCache this extension method operates on.
id
Type: Soss.ClientCachedObjectId
a CachedObjectId which identifies the object in the cache.
obj
Type: SystemObject
Serializable object to store in the cache. The argument cannot be null.
updateIfExists
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.
lockAfterInsert
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).
Exceptions

ExceptionCondition
ArgumentNullException when id null.
Remarks

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

Reference