Table of Contents

Method AddExclusiveAsync

Namespace
Scaleout.Client
Assembly
Scaleout.Client.dll

AddExclusiveAsync(TKey, TValue, CreatePolicy, IEnumerable<string>, CancellationToken)

Add an object in the cache and exclusively locks it, returning a CacheResponse<TKey, TValue> containing a lock token.

public Task<CacheResponse<TKey, TValue>> AddExclusiveAsync(TKey key, TValue value, CreatePolicy createPolicy = null, IEnumerable<string> tags = null, CancellationToken cancellationToken = default)

Parameters

key TKey

Identifier of the object in the cache.

value TValue

Value to be stored in the cache.

createPolicy CreatePolicy

The policy to be associated with the new object. If null, the default policy for the cache will be used.

tags IEnumerable<string>

Collection of tags to associate with the object. Pass null for no tags.

cancellationToken CancellationToken

A token used to propagate notification that this operation should be canceled.

Returns

Task<CacheResponse<TKey, TValue>>

A CacheResponse<TKey, TValue> containing the outcome of the operation and a lock token that can be used for subsequent locking operations against the newly added object.

Remarks

The Result property of the response will contain one of the following ServerResult outcomes:

ServerResultDescription
AddedA new object was successfully added in the ScaleOut service and was left in a locked state.
AlreadyExistsError The object could not be added because another object with the same key already exists in the ScaleOut service.

Use the lock token on the response's LockToken property to perform subsequent operations under the lock.