ConcurrencyLimiterBuilder
class ConcurrencyLimiterBuilder
Traits
Properties
| int | $maxLocks | The maximum number of entities that can hold the lock at the same time. |
|
| int | $releaseAfter | The number of seconds to maintain the lock until it is automatically released. |
|
| 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 number of seconds until the lock will be released.
Set the amount of time to block until a lock is available.
Set the number of milliseconds to wait between lock acquisition attempts.
Acquire a lease on one of the limiter's slots, waiting up to the configured timeout.
Execute the given callback if a lock is obtained, otherwise call the failure callback.
Create the concurrency limiter instance.
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 44
__construct(RedisProxy $connection, string $name)
Create a new builder instance.
at line 53
ConcurrencyLimiterBuilder
limit(int $maxLocks)
Set the maximum number of locks that can be obtained per time window.
at line 63
ConcurrencyLimiterBuilder
releaseAfter(DateTimeInterface|DateInterval|int $releaseAfter)
Set the number of seconds until the lock will be released.
at line 73
ConcurrencyLimiterBuilder
block(int $timeout)
Set the amount of time to block until a lock is available.
at line 83
ConcurrencyLimiterBuilder
sleep(int $sleep)
Set the number of milliseconds to wait between lock acquisition attempts.
at line 95
ConcurrencyLease
acquire()
Acquire a lease on one of the limiter's slots, waiting up to the configured timeout.
at line 105
mixed
then(callable $callback, callable|null $failure = null)
Execute the given callback if a lock is obtained, otherwise call the failure callback.
at line 143
protected ConcurrencyLimiter
createLimiter()
Create the concurrency limiter instance.