Documentation

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

$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
throws
RedisException
throws
LogicException

__destruct()

public final __destruct() : mixed

extend()

public final extend([int|null $ttl = null ]) : bool
Parameters
$ttl : int|null = null
Return values
bool

getKey()

public final getKey() : string
Return values
string

getValidityTime()

public final getValidityTime() : int
Return values
int

microtime

release()

public final release() : bool
Return values
bool

isLocked()

protected final isLocked() : bool
Return values
bool

isOwned()

protected final isOwned() : bool
Return values
bool

getLockKey()

private final getLockKey() : mixed

        
On this page

Search results