RateLimiter
class RateLimiter (View source)
Traits
Properties
protected Repository | $cache | The cache store implementation. |
|
protected array | $limiters | The configured limit object resolvers. |
Methods
Get the number of seconds until the given DateTime.
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.
Increment (by 1) the counter for a given key for a given decay time.
Increment the counter for a given key for a given decay time by a given amount.
Decrement the counter for a given key for a given decay time by a given amount.
Get the number of attempts for the given key.
Reset the number of attempts for the given key.
Get the number of retries left for the given key.
Get the number of retries left for the given key.
Clear the hits and lockout timer for the given key.
Get the number of seconds until the "key" is accessible again.
Clean the rate limiter key from unicode characters.
Execute the given callback without serialization or compression when applicable.
Details
protected int
secondsUntil(DateTimeInterface|DateInterval|int $delay)
Get the number of seconds until the given DateTime.
protected int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)
Get the "available at" UNIX timestamp.
protected DateTimeInterface|int
parseDateInterval(DateTimeInterface|DateInterval|int $delay)
If the given value is an interval, convert it to a DateTime instance.
protected string
runTimeForHumans(float $startTime, float $endTime = null)
Given a start time, format the total run time for human readability.
$this
for(BackedEnum|UnitEnum|string $name, Closure $callback)
Register a named limiter configuration.
mixed
attempt(string $key, int $maxAttempts, Closure $callback, int $decaySeconds = 60)
Attempts to execute a callback if it's not limited.
bool
tooManyAttempts(string $key, int $maxAttempts)
Determine if the given key has been "accessed" too many times.
int
hit(string $key, int $decaySeconds = 60)
Increment (by 1) the counter for a given key for a given decay time.
int
increment(string $key, int $decaySeconds = 60, int $amount = 1)
Increment the counter for a given key for a given decay time by a given amount.
int
decrement(string $key, int $decaySeconds = 60, int $amount = 1)
Decrement the counter for a given key for a given decay time by a given amount.