RdbMutex
in package
implements
MutexInterface
Table of Contents
Interfaces
- MutexInterface
- A locking mechanism.
Constants
- LUA_RELEASE : mixed = <<<LUA if redis.call("GET", KEYS[1]) == ARGV[1]...
Properties
- $autoExpire : int
- $autoRelease : bool
- $name : string
- $prefix : string
- $rdb : Rdb
- $value : string|null
Methods
- __construct() : mixed
- __destruct() : mixed
- acquire() : bool
- Acquire the lock.
- release() : bool
- Release the lock.
- resume() : bool
- Join with an existing mutex.
- generateValue() : string
- Generate a value for the mutex.
- getKey() : string
- Get the full key for this mutex.
- tryAcquire() : bool
- Try to acquire the mutex.
Constants
LUA_RELEASE
public
mixed
LUA_RELEASE
= <<<LUA
if redis.call("GET", KEYS[1]) == ARGV[1] then
return redis.call("DEL", KEYS[1])
else
return 0
end
LUA
Properties
$autoExpire
public
int
$autoExpire
= 60
in seconds, 0 for infinite
$autoRelease
public
bool
$autoRelease
= true
$name
public
string
$name
$prefix
public
string
$prefix
= 'mutex:'
$rdb
public
Rdb
$rdb
$value
protected
string|null
$value
= null
Methods
__construct()
public
__construct(Rdb $rdb, string $name) : mixed
Parameters
- $rdb : Rdb
- $name : string
__destruct()
public
__destruct() : mixed
Tags
acquire()
Acquire the lock.
public
acquire([float $timeout = 0 ]) : bool
Parameters
- $timeout : float = 0
-
in seconds
Tags
Return values
boolrelease()
Release the lock.
public
release() : bool
Tags
Return values
boolresume()
Join with an existing mutex.
public
resume() : bool
Return values
bool —if successful and locked, otherwise unlocked.
generateValue()
Generate a value for the mutex.
protected
generateValue() : string
Return values
stringgetKey()
Get the full key for this mutex.
protected
getKey() : string
Return values
stringtryAcquire()
Try to acquire the mutex.
protected
tryAcquire() : bool