Documentation

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

$prefix

public string $prefix = 'mutex:'

$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
inheritdoc

acquire()

Acquire the lock.

public acquire([float $timeout = 0 ]) : bool
Parameters
$timeout : float = 0

in seconds

Tags
inheritdoc
Return values
bool

release()

Release the lock.

public release() : bool
Tags
inheritdoc
Return values
bool

resume()

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
string

getKey()

Get the full key for this mutex.

protected getKey() : string
Return values
string

tryAcquire()

Try to acquire the mutex.

protected tryAcquire() : bool
Return values
bool
On this page

Search results