ConcurrencyLimiter
class ConcurrencyLimiter
Properties
| protected list<string> | $slots | Precomputed slot names. Built once in the constructor. |
|
| protected string | $keyPrefix | The slot key prefix. |
Methods
__construct(RedisProxy $redis, string $name, int $maxLocks, int $releaseAfter)
Create a new concurrency limiter instance.
acquire(int $timeout, int $sleep = 250)
Acquire a lease on one of the limiter's slots, waiting up to the given timeout.
mixed
block(int $timeout, callable|null $callback = null, int $sleep = 250)
Attempt to acquire the lock for the given number of seconds.
false|string
claimSlot(string $id)
Attempt to claim a free slot.
Details
at line 39
__construct(RedisProxy $redis, string $name, int $maxLocks, int $releaseAfter)
Create a new concurrency limiter instance.
at line 61
ConcurrencyLease
acquire(int $timeout, int $sleep = 250)
Acquire a lease on one of the limiter's slots, waiting up to the given timeout.
at line 92
mixed
block(int $timeout, callable|null $callback = null, int $sleep = 250)
Attempt to acquire the lock for the given number of seconds.
When no callback is given, the slot is reserved fire-and-forget: it is held until the releaseAfter TTL reclaims it. Use acquire() to obtain a releasable lease instead.
at line 128
protected false|string
claimSlot(string $id)
Attempt to claim a free slot.