RateLimitedWithRedis
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
Create a new middleware instance.
Handle a rate limited job.
Set the delay (in seconds) to release the job back to the queue.
Do not release the job back to the queue if the limit is exceeded.
Get the number of seconds that should elapse before the job is retried.
Prepare the object for serialization.
Prepare the object after unserialization.
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Determine if the given key has been "accessed" too many times.
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.
in
RateLimited at line 53
mixed
handle(mixed $job, callable $next)
Process the job.
at line 40
protected mixed
handleJob(mixed $job, callable $next, array $limits)
Handle a rate limited job.
in
RateLimited at line 102
RateLimited
releaseAfter(DateTimeInterface|int $releaseAfter)
Set the delay (in seconds) to release the job back to the queue.
in
RateLimited at line 112
RateLimited
dontRelease()
Do not release the job back to the queue if the limit is exceeded.
at line 77
protected int
getTimeUntilNextRetry(string $key)
Get the number of seconds that should elapse before the job is retried.
at line 95
array
__sleep()
Prepare the object for serialization.
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.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
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.
in
InteractsWithTime at line 57
protected int
currentTime()
Get the current system time as a UNIX timestamp.
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.
at line 56
protected bool
tooManyAttempts(string $key, int $maxAttempts, int $decaySeconds)
Determine if the given key has been "accessed" too many times.
at line 85
RateLimitedWithRedis
connection(string $name)
Specify the Redis connection that should be used.