ConcurrencyLimiter
in package
Table of Contents
- $maxLocks : int
- The allowed number of concurrent tasks.
- $name : string
- The name of the limiter.
- $redis : Connection
- The Redis factory implementation.
- $releaseAfter : int
- The number of seconds a slot should be maintained.
- __construct() : void
- Create a new concurrency limiter instance.
- block() : bool
- Attempt to acquire the lock for the given number of seconds.
- acquire() : mixed
- Attempt to acquire the lock.
- luaScript() : string
- Get the Lua script for acquiring a lock.
- release() : void
- Release the lock.
Properties
$maxLocks
The allowed number of concurrent tasks.
protected
int
$maxLocks
$name
The name of the limiter.
protected
string
$name
$redis
The Redis factory implementation.
protected
Connection
$redis
$releaseAfter
The number of seconds a slot should be maintained.
protected
int
$releaseAfter
Methods
__construct()
Create a new concurrency limiter instance.
public
__construct(Connection $redis, string $name, int $maxLocks, int $releaseAfter) : void
Parameters
- $redis : Connection
- $name : string
- $maxLocks : int
- $releaseAfter : int
Return values
void —block()
Attempt to acquire the lock for the given number of seconds.
public
block(int $timeout[, callable|null $callback = null ]) : bool
Parameters
- $timeout : int
- $callback : callable|null = null
Tags
Return values
bool —acquire()
Attempt to acquire the lock.
protected
acquire() : mixed
Return values
mixed —luaScript()
Get the Lua script for acquiring a lock.
protected
luaScript() : string
KEYS - The keys that represent available slots ARGV[1] - The limiter name ARGV[2] - The number of seconds the slot should be reserved
Return values
string —release()
Release the lock.
protected
release(string $key) : void
Parameters
- $key : string