Spec-Zone.ru › Laravel 8

ThrottleRequestsWithRedis

class ThrottleRequestsWithRedis extends ThrottleRequests (View source)

Свойства

protected RateLimiter $limiter

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

from ThrottleRequests
protected Factory $redis

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

array $decaysAt

Отметка времени окончания текущего интервала по ключу.

array $remaining

Количество оставшихся слотов по ключу.

Трейты

InteractsWithTime

Методы

int secondsUntil(DateTimeInterface|DateInterval|int $delay)

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

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

Получить UNIX-временную метку "доступно в".

из InteractsWithTime
DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

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

из InteractsWithTime
int currentTime()

Получить текущее системное время в виде UNIX-временной метки.

из InteractsWithTime
void __construct(RateLimiter $limiter, Factory $redis)

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

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

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

из ThrottleRequests
Response handleRequestUsingNamedLimiter(Request $request, Closure $next, string $limiterName, Closure $limiter)

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

из ThrottleRequests
Response handleRequest(Request $request, Closure $next, array $limits)

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

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

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

из ThrottleRequests
string resolveRequestSignature(Request $request)

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

из ThrottleRequests
ThrottleRequestsException buildException(Request $request, string $key, int $maxAttempts, callable|null $responseCallback = null)

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

из ThrottleRequests
int getTimeUntilNextRetry(string $key)

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

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

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

из ThrottleRequests
array getHeaders(int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null, Response|null $response = null)

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

из 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)

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

Параметры

DateTimeInterface|DateInterval|int $delay

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

int

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

Получить UNIX-временную метку "доступно в".

Параметры

DateTimeInterface|DateInterval|int $delay

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

int

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

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

Параметры

DateTimeInterface|DateInterval|int $delay

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

DateTimeInterface|int

protected int currentTime()

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

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

int

void __construct(RateLimiter $limiter, Factory $redis)

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

Параметры

RateLimiter $limiter
Factory $redis

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

void

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

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

Параметры

Request $request
Closure $next
int|string $maxAttempts
float|int $decayMinutes
string $prefix

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

Response

Исключения

ThrottleRequestsException

protected Response handleRequestUsingNamedLimiter(Request $request, Closure $next, string $limiterName, Closure $limiter)

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

Параметры

Request $request
Closure $next
string $limiterName
Closure $limiter

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

Response

Исключения

ThrottleRequestsException

protected Response handleRequest(Request $request, Closure $next, array $limits)

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

Параметры

Request $request
Closure $next
array $limits

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

Response

Исключения

ThrottleRequestsException

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

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

Параметры

Request $request
int|string $maxAttempts

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

int

protected string resolveRequestSignature(Request $request)

Получить подпись запроса.

Parameters

Request $request

Return Value

string

Exceptions

RuntimeException

protected ThrottleRequestsException buildException(Request $request, string $key, int $maxAttempts, callable|null $responseCallback = null)

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

Parameters

Request $request
string $key
int $maxAttempts
callable|null $responseCallback

Return Value

ThrottleRequestsException

protected int getTimeUntilNextRetry(string $key)

Получить количество секунд до следующей попытки.

Parameters

string $key

Return Value

int

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

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

Parameters

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

Return Value

Response

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

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

Parameters

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

Return Value

array

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

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

Parameters

string $key
int $maxAttempts
int|null $retryAfter

Return Value

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/8.x/Illuminate/Routing/Middleware/ThrottleRequestsWithRedis.html

Spec-Zone.ru

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