RateLimiter

class RateLimiter (View source)

Traits

InteractsWithTime

Properties

protected Repository $cache The cache store implementation.

Methods

int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

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

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
void __construct(Repository $cache)

Create a new rate limiter instance.

bool tooManyAttempts(string $key, int $maxAttempts)

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

int hit(string $key, float|int $decayMinutes = 1)

Increment the counter for a given key for a given decay time.

mixed attempts(string $key)

Get the number of attempts for the given key.

mixed resetAttempts(string $key)

Reset the number of attempts for the given key.

int retriesLeft(string $key, int $maxAttempts)

Get the number of retries left for the given key.

void clear(string $key)

Clear the hits and lockout timer for the given key.

int availableIn(string $key)

Get the number of seconds until the "key" is accessible again.

Details

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)

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

void __construct(Repository $cache)

Create a new rate limiter instance.

Parameters

Repository $cache

Return Value

void

bool tooManyAttempts(string $key, int $maxAttempts)

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

Parameters

string $key
int $maxAttempts

Return Value

bool

int hit(string $key, float|int $decayMinutes = 1)

Increment the counter for a given key for a given decay time.

Parameters

string $key
float|int $decayMinutes

Return Value

int

mixed attempts(string $key)

Get the number of attempts for the given key.

Parameters

string $key

Return Value

mixed

mixed resetAttempts(string $key)

Reset the number of attempts for the given key.

Parameters

string $key

Return Value

mixed

int retriesLeft(string $key, int $maxAttempts)

Get the number of retries left for the given key.

Parameters

string $key
int $maxAttempts

Return Value

int

void clear(string $key)

Clear the hits and lockout timer for the given key.

Parameters

string $key

Return Value

void

int availableIn(string $key)

Get the number of seconds until the "key" is accessible again.

Parameters

string $key

Return Value

int

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.6/Illuminate/Cache/RateLimiter.html