RedisLock
in package
Table of Contents
Constants
- CLOCK_DRIFT_FACTOR = 0.01
- LOCK_PREFIX = "lock-"
Properties
- $acquired : bool
- $drift : mixed
- $key : string
- $redis : Redis
- $retryCount : int
- $retryDelay : int
- $throwException : bool
- $token : string
- $ttl : int
- $validityTime : int
Methods
- __construct() : mixed
- __destruct() : mixed
- acquire() : mixed
- extend() : bool
- getKey() : string
- getValidityTime() : int
- isValid() : mixed
- release() : bool
- isLocked() : bool
- isOwned() : bool
- getLockKey() : mixed
Constants
CLOCK_DRIFT_FACTOR
public
mixed
CLOCK_DRIFT_FACTOR
= 0.01
LOCK_PREFIX
public
mixed
LOCK_PREFIX
= "lock-"
Properties
$acquired
protected
bool
$acquired
= false
$drift
protected
mixed
$drift
$key
protected
string
$key
$redis
protected
Redis
$redis
$retryCount
protected
int
$retryCount
= 3
$retryDelay
protected
int
$retryDelay
= 200
miliseconds
$throwException
protected
bool
$throwException
= true
If true, failure to acquire or release a lock will throw an exception.
$token
protected
string
$token
generated when instance is created
$ttl
protected
int
$ttl
miliseconds - Time To Live
$validityTime
private
int
$validityTime
= 0
microtime
Methods
__construct()
public
final __construct(Redis $redis, string $key[, null|int $ttl = 3000 ][, null|int $retryDelay = 200 ][, null|int $retryCount = 10 ][, null|bool $throwException = true ]) : mixed
Parameters
- $redis : Redis
-
- Throws \RedisException if instance is not connected
- $key : string
-
Throws \LogicException if key is an empty string
- $ttl : null|int = 3000
-
miliseconds - Time To Live
- $retryDelay : null|int = 200
-
miliseconds
- $retryCount : null|int = 10
-
defaults to zero if value is negative
- $throwException : null|bool = true
-
If true, acquire will throw an exception on failure. Returns false otherwise.
Tags
__destruct()
public
final __destruct() : mixed
acquire()
public
final acquire() : mixed
Tags
extend()
public
final extend([int|null $ttl = null ]) : bool
Parameters
- $ttl : int|null = null
Return values
boolgetKey()
public
final getKey() : string
Return values
stringgetValidityTime()
public
final getValidityTime() : int
Return values
int —microtime
isValid()
public
final isValid() : mixed
release()
public
final release() : bool
Return values
boolisLocked()
protected
final isLocked() : bool
Return values
boolisOwned()
protected
final isOwned() : bool
Return values
boolgetLockKey()
private
final getLockKey() : mixed