Skip to main content

DistributedLock

Assembly: ServiceStack.Redis.dll
View Source
Declaration
public class DistributedLock : IDistributedLockAsync, IDistributedLock

Fields

LOCK_NOT_ACQUIRED

View Source
Declaration
public const int LOCK_NOT_ACQUIRED = 0

LOCK_ACQUIRED

View Source
Declaration
public const int LOCK_ACQUIRED = 1

LOCK_RECOVERED

View Source
Declaration
public const int LOCK_RECOVERED = 2

Methods

AsAsync()

View Source
Declaration
public IDistributedLockAsync AsAsync()
Returns

ServiceStack.Redis.Support.Locking.IDistributedLockAsync

IDistributedLockAsync.LockAsync(String, Int32, Int32, IRedisClientAsync, CancellationToken)

View Source
Declaration
async ValueTask<LockState> IDistributedLockAsync.LockAsync(string key, int acquisitionTimeout, int lockTimeout, IRedisClientAsync client, CancellationToken token)
Returns

ValueTask<ServiceStack.Redis.Support.Locking.LockState>

Parameters
TypeName
System.Stringkey
System.Int32acquisitionTimeout
System.Int32lockTimeout
ServiceStack.Redis.IRedisClientAsyncclient
System.Threading.CancellationTokentoken

IDistributedLockAsync.UnlockAsync(String, Int64, IRedisClientAsync, CancellationToken)

View Source
Declaration
async ValueTask<bool> IDistributedLockAsync.UnlockAsync(string key, long lockExpire, IRedisClientAsync client, CancellationToken token)
Returns

ValueTask<System.Boolean>

Parameters
TypeName
System.Stringkey
System.Int64lockExpire
ServiceStack.Redis.IRedisClientAsyncclient
System.Threading.CancellationTokentoken

Lock(String, Int32, Int32, out Int64, IRedisClient)

acquire distributed, non-reentrant lock on key

View Source
Declaration
public virtual long Lock(string key, int acquisitionTimeout, int lockTimeout, out long lockExpire, IRedisClient client)
Returns

System.Int64

Parameters
TypeNameDescription
System.Stringkeyglobal key for this lock

| | System.Int32 | acquisitionTimeout | timeout for acquiring lock

| | System.Int32 | lockTimeout | timeout for lock, in seconds (stored as value against lock key)

| | System.Int64 | lockExpire |

| | ServiceStack.Redis.IRedisClient | client |

|

Unlock(String, Int64, IRedisClient)

unlock key

View Source
Declaration
public virtual bool Unlock(string key, long lockExpire, IRedisClient client)
Returns

System.Boolean

Parameters
TypeName
System.Stringkey
System.Int64lockExpire
ServiceStack.Redis.IRedisClientclient

Implements