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: 6.2.0.0
Syntax
public static Task<AsyncPutResult> InsertAsync( this NamedCache cache, string id, Object obj, bool updateIfExists, bool lockAfterInsert, CreatePolicy createPolicy = null, CancellationToken cancellationToken = null )
Parameters
- cache
- Type: Soss.Client.NamedCache
the NamedCache this extension method operates on. - id
- Type: System.String
a String that will be transformed into a CachedObjectId via CreateKey(String) which identifies the object in the cache. - obj
- Type: System.Object
Serializable object to store in the cache. The argument cannot be null. - updateIfExists
- Type: System.Boolean
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: System.Boolean
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.Client.CreatePolicy
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.Threading.CancellationToken
An optional CancellationToken that can be used to cancel the asynchronous operation.
Return Value
Type: Task<AsyncPutResult>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
Exception | Condition |
---|---|
ArgumentNullException | when id null. |
Remarks
See Also