ConcurrencyLimiterBuilder
class ConcurrencyLimiterBuilder (View source)
Traits
Properties
Connection | $connection | The Redis connection. | |
string | $name | The name of the lock. | |
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. |
Methods
Get the number of seconds until the given DateTime.
If the given value is an interval, convert it to a DateTime instance.
Set the maximum number of locks that can 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.
Execute the given callback if a lock is obtained, otherwise call the failure callback.
Details
in InteractsWithTime at line 16
protected int
secondsUntil(DateTimeInterface|DateInterval|int $delay)
Get the number of seconds until the given DateTime.
in InteractsWithTime at line 31
protected int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)
Get the "available at" UNIX timestamp.
in InteractsWithTime at line 46
protected DateTimeInterface|int
parseDateInterval(DateTimeInterface|DateInterval|int $delay)
If the given value is an interval, convert it to a DateTime instance.
in InteractsWithTime at line 60
protected int
currentTime()
Get the current system time as a UNIX timestamp.
at line 54
void
__construct(Connection $connection, string $name)
Create a new builder instance.
at line 66
$this
limit(int $maxLocks)
Set the maximum number of locks that can obtained per time window.
at line 79
$this
releaseAfter(int $releaseAfter)
Set the number of seconds until the lock will be released.
at line 92
$this
block(int $timeout)
Set the amount of time to block until a lock is available.
at line 108
mixed
then(callable $callback, callable $failure = null)
Execute the given callback if a lock is obtained, otherwise call the failure callback.