On this page
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. |
|
mixed | block(int $timeout, callable|null $callback = null, int $sleep = 250) Attempt to acquire the lock for the given number of seconds. |
|
mixed | acquire(string $id) Attempt to acquire the lock. |
|
string | lockScript() Get the Lua script for acquiring a lock. |
|
void | release(string $key, string $id) Release the lock. |
|
string | releaseScript() Get the Lua script to atomically release a lock. |
Details
void __construct(Connection $redis, string $name, int $maxLocks, int $releaseAfter)
Create a new concurrency limiter instance.
mixed block(int $timeout, callable|null $callback = null, int $sleep = 250)
Attempt to acquire the lock for the given number of seconds.
protected mixed acquire(string $id)
Attempt to acquire the lock.
protected string lockScript()
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 ARGV[3] - The unique identifier for this lock
protected void release(string $key, string $id)
Release the lock.
protected string releaseScript()
Get the Lua script to atomically release a lock.
KEYS[1] - The name of the lock ARGV[1] - The unique identifier for this lock
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/10.x/Illuminate/Redis/Limiters/ConcurrencyLimiter.html