Table of Contents

Method GetExclusiveLock

Namespace
Scaleout.Client
Assembly
Scaleout.Client.dll

GetExclusiveLock(TKey, CancellationToken)

Acquires an exclusive lock on an object in the cache.

public CacheResponse<TKey, TValue> GetExclusiveLock(TKey key, CancellationToken cancellationToken = default)

Parameters

key TKey

Identifier of the object in the cache.

cancellationToken CancellationToken

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

Returns

CacheResponse<TKey, TValue>

A CacheResponse<TKey, TValue> containing the outcome of the operation and (if successful) a lock token.

Remarks

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

ServerResultDescription
LockedThe object was successfully locked in the ScaleOut service.
NotFoundThe requested object was not found in the ScaleOut service.

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

Use the cancellationToken parameter to control the amount of time the caller should wait to acquire the exclusive lock.