ConcurrencyLimiter

class ConcurrencyLimiter (View source)

Properties

protected Connection $redis The Redis factory implementation.
protected string $name The name of the limiter.
protected int $maxLocks The allowed number of concurrent tasks.
protected int $releaseAfter The number of seconds a slot should be maintained.

Methods

void __construct(Connection $redis, string $name, int $maxLocks, int $releaseAfter)

Create a new concurrency limiter instance.

bool block(int $timeout, callable|null $callback = null)

Attempt to acquire the lock for the given number of seconds.

mixed acquire()

Attempt to acquire the lock.

string luaScript()

Get the Lua script for acquiring a lock.

void release(string $key)

Release the lock.

Details

void __construct(Connection $redis, string $name, int $maxLocks, int $releaseAfter)

Create a new concurrency limiter instance.

Parameters

Connection $redis
string $name
int $maxLocks
int $releaseAfter

Return Value

void

bool block(int $timeout, callable|null $callback = null)

Attempt to acquire the lock for the given number of seconds.

Parameters

int $timeout
callable|null $callback

Return Value

bool

Exceptions

LimiterTimeoutException
Exception

protected mixed acquire()

Attempt to acquire the lock.

Return Value

mixed

protected string luaScript()

Get the Lua script for acquiring a lock.

KEYS - The keys that represent available slots ARGV[1] - The limiter name ARGV[2] - The number of seconds the slot should be reserved

Return Value

string

protected void release(string $key)

Release the lock.

Parameters

string $key

Return Value

void

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.7/Illuminate/Redis/Limiters/ConcurrencyLimiter.html