Spec-Zone.ru › Laravel 6

ThrottleRequestsWithRedis

class ThrottleRequestsWithRedis extends ThrottleRequests (View source)

Свойства

InteractsWithTime

Свойства

protected RateLimiter $limiter

Экземпляр лимитера.

from ThrottleRequests
protected Factory $redis

Реализация фабрики Redis.

int $decaysAt

Маркер времени окончания текущей продолжительности.

int $remaining

Количество оставшихся слотов.

Методы

int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Получить количество секунд до указанной даты и времени.

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

Получить отметку времени "доступно в" в формате Unix Timestamp.

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

Если заданное значение является интервалом, преобразовать его в экземпляр DateTime.

from InteractsWithTime
int currentTime()

Получить текущее системное время в формате Unix Timestamp.

from InteractsWithTime
void __construct(Factory $redis)

Создать новый лимитер запросов.

Response handle(Request $request, Closure $next, int|string $maxAttempts = 60, float|int $decayMinutes = 1, string $prefix = '')

Обработать входящий запрос.

int resolveMaxAttempts(Request $request, int|string $maxAttempts)

Определить количество попыток, если пользователь авторизован или нет.

from ThrottleRequests
string resolveRequestSignature(Request $request)

Определить подпись запроса.

from ThrottleRequests
ThrottleRequestsException buildException(string $key, int $maxAttempts)

Создать исключение "слишком много попыток".

from ThrottleRequests
int getTimeUntilNextRetry(string $key)

Получить количество секунд до сброса блокировки.

Response addHeaders(Response $response, int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null)

Добавить информацию о лимите в заголовки ответа.

from ThrottleRequests
array getHeaders(int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null)

Получить информацию о заголовках лимита.

from ThrottleRequests
int calculateRemainingAttempts(string $key, int $maxAttempts, int|null $retryAfter = null)

Вычислить оставшееся количество попыток.

mixed tooManyAttempts(string $key, int $maxAttempts, int $decayMinutes)

Определить, было ли к заданному ключу слишком много обращений.

Подробное описание

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

Получить количество секунд до указанной даты и времени.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

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

Получить отметку времени "доступно в" в формате Unix Timestamp.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

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

Если заданное значение является интервалом, преобразовать его в экземпляр DateTime.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

DateTimeInterface|int

protected int currentTime()

Получить текущее системное время в формате Unix Timestamp.

Return Value

int

void __construct(Factory $redis)

Создать новый лимитер запросов.

Parameters

Factory $redis

Return Value

void

Ответ handle(Запрос $request, Closure $next, int|string $maxAttempts = 60, float|int $decayMinutes = 1, string $prefix = '')

Обработка входящего запроса.

Параметры

Запрос $request
Closure $next
int|string $maxAttempts
float|int $decayMinutes
string $prefix

Возвращаемое значение

Ответ

Исключения

HttpException

protected int resolveMaxAttempts(Запрос $request, int|string $maxAttempts)

Определение количества попыток, если пользователь авторизован или нет.

Параметры

Запрос $request
int|string $maxAttempts

Возвращаемое значение

int

protected string resolveRequestSignature(Запрос $request)

Определение подписи запроса.

Параметры

Запрос $request

Возвращаемое значение

string

Исключения

RuntimeException

protected ThrottleRequestsException buildException(string $key, int $maxAttempts)

Создание исключения «слишком много попыток».

Параметры

string $key
int $maxAttempts

Возвращаемое значение

ThrottleRequestsException

protected int getTimeUntilNextRetry(string $key)

Получение количества секунд до снятия блокировки.

Параметры

string $key

Возвращаемое значение

int

protected Response addHeaders(Response $response, int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null)

Добавление информации о лимите в заданный ответ.

Параметры

Response $response
int $maxAttempts
int $remainingAttempts
int|null $retryAfter

Возвращаемое значение

Response

protected array getHeaders(int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null)

Получение информации о заголовках лимита.

Параметры

int $maxAttempts
int $remainingAttempts
int|null $retryAfter

Возвращаемое значение

array

protected int calculateRemainingAttempts(string $key, int $maxAttempts, int|null $retryAfter = null)

Вычисление количества оставшихся попыток.

Параметры

string $key
int $maxAttempts
int|null $retryAfter

Возвращаемое значение

int

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

Определение, превышено ли количество попыток для данного ключа.

Параметры

string $key
int $maxAttempts
int $decayMinutes

Возвращаемое значение

mixed

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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API