DurationLimiter
class DurationLimiter
Properties
| int|null | $decaysAt | The timestamp of the end of the current duration. |
|
| int|null | $remaining | The number of remaining slots. |
Methods
Create a new duration limiter instance.
Attempt to acquire the lock for the given number of seconds.
Attempt to acquire the lock.
Determine if the key has been "accessed" too many times.
Clear the limiter.
Get the Lua script for acquiring a lock.
Get the Lua script to determine if the key has been "accessed" too many times.
Details
at line 33
__construct(RedisProxy $redis, string $name, int $maxLocks, int $decay)
Create a new duration limiter instance.
at line 46
mixed
block(int $timeout, callable|null $callback = null, int $sleep = 750)
Attempt to acquire the lock for the given number of seconds.
at line 72
bool
acquire()
Attempt to acquire the lock.
at line 94
bool
tooManyAttempts()
Determine if the key has been "accessed" too many times.
at line 115
void
clear()
Clear the limiter.
at line 129
protected string
luaScript()
Get the Lua script for acquiring a lock.
KEYS[1] - The limiter name ARGV[1] - Current time in microseconds ARGV[2] - Current time in seconds ARGV[3] - Duration of the bucket ARGV[4] - Allowed number of tasks
at line 162
protected string
tooManyAttemptsLuaScript()
Get the Lua script to determine if the key has been "accessed" too many times.
KEYS[1] - The limiter name ARGV[1] - Current time in microseconds ARGV[2] - Current time in seconds ARGV[3] - Duration of the bucket ARGV[4] - Allowed number of tasks