DurationLimiterBuilder
class DurationLimiterBuilder
Traits
Properties
| int | $maxLocks | The maximum number of locks that can be obtained per time window. |
|
| int | $decay | The amount of time the lock window is maintained. |
|
| int | $timeout | The amount of time to block until a lock is available. |
|
| int | $sleep | The number of milliseconds to wait between attempts to acquire the lock. |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Set the maximum number of locks that can be obtained per time window.
Set the amount of time the lock window is maintained.
Set the amount of time to block until a lock is available.
Set the number of milliseconds to wait between lock acquisition attempts.
Execute the given callback if a lock is obtained, otherwise call the failure callback.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 41
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 57
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 65
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
at line 43
__construct(RedisProxy $connection, string $name)
Create a new builder instance.
at line 52
DurationLimiterBuilder
allow(int $maxLocks)
Set the maximum number of locks that can be obtained per time window.
at line 62
DurationLimiterBuilder
every(DateTimeInterface|DateInterval|int $decay)
Set the amount of time the lock window is maintained.
at line 72
DurationLimiterBuilder
block(int $timeout)
Set the amount of time to block until a lock is available.
at line 82
DurationLimiterBuilder
sleep(int $sleep)
Set the number of milliseconds to wait between lock acquisition attempts.
at line 94
mixed
then(callable $callback, callable|null $failure = null)
Execute the given callback if a lock is obtained, otherwise call the failure callback.