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
Type | Name |
---|---|
System.String | key |
System.Int32 | acquisitionTimeout |
System.Int32 | lockTimeout |
ServiceStack.Redis.IRedisClientAsync | client |
System.Threading.CancellationToken | token |
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
Type | Name |
---|---|
System.String | key |
System.Int64 | lockExpire |
ServiceStack.Redis.IRedisClientAsync | client |
System.Threading.CancellationToken | token |
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
Type | Name | Description |
---|---|---|
System.String | key | global 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
Type | Name |
---|---|
System.String | key |
System.Int64 | lockExpire |
ServiceStack.Redis.IRedisClient | client |