RateLimitedWithRedis

class RateLimitedWithRedis extends RateLimited (View source)

Traits

InteractsWithTime

Properties

protected RateLimiter $limiter The rate limiter instance. from RateLimited
protected string $limiterName The name of the rate limiter. from RateLimited
bool $shouldRelease Indicates if the job should be released if the limit is exceeded. from RateLimited
protected Factory $redis The Redis factory implementation.
array $decaysAt The timestamp of the end of the current duration by key.

Methods

void __construct(string $limiterName)

Create a new middleware instance.

mixed handle(mixed $job, callable $next)

Process the job.

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

Handle a rate limited job.

$this dontRelease()

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

from RateLimited
int getTimeUntilNextRetry(string $key)

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

int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

from InteractsWithTime
int availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Get the "available at" UNIX timestamp.

from InteractsWithTime
DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

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

from InteractsWithTime
int currentTime()

Get the current system time as a UNIX timestamp.

from InteractsWithTime
bool tooManyAttempts(string $key, int $maxAttempts, int $decayMinutes)

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

Details

void __construct(string $limiterName)

Create a new middleware instance.

Parameters

string $limiterName

Return Value

void

mixed handle(mixed $job, callable $next)

Process the job.

Parameters

mixed $job
callable $next

Return Value

mixed

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

Handle a rate limited job.

Parameters

mixed $job
callable $next
array $limits

Return Value

mixed

$this dontRelease()

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

Return Value

$this

protected int getTimeUntilNextRetry(string $key)

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

Parameters

string $key

Return Value

int

protected int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

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

Get the "available at" UNIX timestamp.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

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

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

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

DateTimeInterface|int

protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

protected bool tooManyAttempts(string $key, int $maxAttempts, int $decayMinutes)

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

Parameters

string $key
int $maxAttempts
int $decayMinutes

Return Value

bool

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Queue/Middleware/RateLimitedWithRedis.html