class RateLimitedWithRedis extends RateLimited (View source)

Traits

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(BackedEnum|UnitEnum|string $limiterName)

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.

$this
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.

void
__wakeup()

Prepare the object after unserialization.

int
secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

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

Get the "available at" UNIX timestamp.

parseDateInterval(DateTimeInterface|DateInterval|int $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 $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.

Details

void __construct(BackedEnum|UnitEnum|string $limiterName)

Create a new middleware instance.

Parameters

BackedEnum|UnitEnum|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 the 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

array __sleep()

Prepare the object for serialization.

Return Value

array

void __wakeup()

Prepare the object after unserialization.

Return Value

void

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 string runTimeForHumans(float $startTime, float $endTime = null)

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

Parameters

float $startTime
float $endTime

Return Value

string

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

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.