Documentation

ConcurrencyLimiterBuilder
in package
Uses InteractsWithTime

Table of Contents

$connection  : Connection
The Redis connection.
$maxLocks  : int
The maximum number of entities that can hold the lock at the same time.
$name  : string
The name of the lock.
$releaseAfter  : int
The number of seconds to maintain the lock until it is automatically released.
$timeout  : int
The amount of time to block until a lock is available.
__construct()  : void
Create a new builder instance.
block()  : $this
Set the amount of time to block until a lock is available.
limit()  : $this
Set the maximum number of locks that can obtained per time window.
releaseAfter()  : $this
Set the number of seconds until the lock will be released.
then()  : mixed
Execute the given callback if a lock is obtained, otherwise call the failure callback.
availableAt()  : int
Get the "available at" UNIX timestamp.
currentTime()  : int
Get the current system time as a UNIX timestamp.
parseDateInterval()  : DateTimeInterface|int
If the given value is an interval, convert it to a DateTime instance.
secondsUntil()  : int
Get the number of seconds until the given DateTime.

Properties

$releaseAfter

The number of seconds to maintain the lock until it is automatically released.

public int $releaseAfter = 60

Methods

block()

Set the amount of time to block until a lock is available.

public block(int $timeout) : $this
Parameters
$timeout : int
Return values
$this

limit()

Set the maximum number of locks that can obtained per time window.

public limit(int $maxLocks) : $this
Parameters
$maxLocks : int
Return values
$this

releaseAfter()

Set the number of seconds until the lock will be released.

public releaseAfter(int $releaseAfter) : $this
Parameters
$releaseAfter : int
Return values
$this

then()

Execute the given callback if a lock is obtained, otherwise call the failure callback.

public then(callable $callback[, callable|null $failure = null ]) : mixed
Parameters
$callback : callable
$failure : callable|null = null
Tags
throws
LimiterTimeoutException
Return values
mixed

availableAt()

Get the "available at" UNIX timestamp.

protected availableAt(DateTimeInterface|DateInterval|int $delay) : int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
int

currentTime()

Get the current system time as a UNIX timestamp.

protected currentTime() : int
Return values
int

parseDateInterval()

If the given value is an interval, convert it to a DateTime instance.

protected parseDateInterval(DateTimeInterface|DateInterval|int $delay) : DateTimeInterface|int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
DateTimeInterface|int

secondsUntil()

Get the number of seconds until the given DateTime.

protected secondsUntil(DateTimeInterface|DateInterval|int $delay) : int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
int

Search results