class RateLimitedWithRedis extends RateLimited

Traits

Properties

protected RateLimiter $limiter

The rate limiter instance.

from  RateLimited
protected string $limiterName

The name of the rate limiter.

from  RateLimited
DateTimeInterface|int|null $releaseAfter

The number of seconds before a job should be available again if the limit is exceeded.

from  RateLimited
bool $shouldRelease

Indicates if the job should be released if the limit is exceeded.

from  RateLimited
protected string|null $connectionName

The name of the Redis connection that should be used.

array $decaysAt

The timestamp of the end of the current duration by key.

Methods

__construct(UnitEnum|string $limiterName, string|null $connection = null)

Create a new middleware instance.

mixed
handle(mixed $job, callable $next)

Process the job.

mixed
handleJob(mixed $job, callable $next, array $limits)

Handle a rate limited job.

releaseAfter(DateTimeInterface|int $releaseAfter)

Set the delay (in seconds) to release the job back to the queue.

dontRelease()

Do not release the job back to the queue if the limit is exceeded.

int
getTimeUntilNextRetry(string $key)

Get the number of seconds that should elapse before the job is retried.

array
__sleep()

Prepare the object for serialization.

__wakeup()

Prepare the object after unserialization.

int
secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

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

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

bool
tooManyAttempts(string $key, int $maxAttempts, int $decaySeconds)

Determine if the given key has been "accessed" too many times.

connection(string $name)

Specify the Redis connection that should be used.

Details

at line 30
__construct(UnitEnum|string $limiterName, string|null $connection = null)

Create a new middleware instance.

Parameters

UnitEnum|string $limiterName
string|null $connection

in RateLimited at line 53
mixed handle(mixed $job, callable $next)

Process the job.

Parameters

mixed $job
callable $next

Return Value

mixed

at line 40
protected mixed handleJob(mixed $job, callable $next, array $limits)

Handle a rate limited job.

Parameters

mixed $job
callable $next
array $limits

Return Value

mixed

in RateLimited at line 102
RateLimited releaseAfter(DateTimeInterface|int $releaseAfter)

Set the delay (in seconds) to release the job back to the queue.

Parameters

DateTimeInterface|int $releaseAfter

Return Value

RateLimited

in RateLimited at line 112
RateLimited dontRelease()

Do not release the job back to the queue if the limit is exceeded.

Return Value

RateLimited

at line 77
protected int getTimeUntilNextRetry(string $key)

Get the number of seconds that should elapse before the job is retried.

Parameters

string $key

Return Value

int

at line 95
array __sleep()

Prepare the object for serialization.

Return Value

array

at line 103
__wakeup()

Prepare the object after unserialization.

in InteractsWithTime at line 17
protected int secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateInterval|DateTimeInterface|int $delay

Return Value

int

in InteractsWithTime at line 29
protected int availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

int

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.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

DateTimeInterface|int

in InteractsWithTime at line 57
protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

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.

Parameters

float $startTime
float|null $endTime

Return Value

string

at line 56
protected bool tooManyAttempts(string $key, int $maxAttempts, int $decaySeconds)

Determine if the given key has been "accessed" too many times.

Parameters

string $key
int $maxAttempts
int $decaySeconds

Return Value

bool

at line 85
RateLimitedWithRedis connection(string $name)

Specify the Redis connection that should be used.

Parameters

string $name

Return Value

RateLimitedWithRedis