RateLimitInterface
in
RateLimitInterface is the interface that may be implemented by an identity object to enforce rate limiting.
Tags
Table of Contents
Methods
- getRateLimit() : array<string|int, mixed>
- Returns the maximum number of allowed requests and the window size.
- loadAllowance() : array<string|int, mixed>
- Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
- saveAllowance() : mixed
- Saves the number of allowed requests and the corresponding timestamp to a persistent storage.
Methods
getRateLimit()
Returns the maximum number of allowed requests and the window size.
public
getRateLimit(Request $request, Action $action) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —an array of two elements. The first element is the maximum number of allowed requests, and the second element is the size of the window in seconds.
loadAllowance()
Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
public
loadAllowance(Request $request, Action $action) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —an array of two elements. The first element is the number of allowed requests, and the second element is the corresponding UNIX timestamp.
saveAllowance()
Saves the number of allowed requests and the corresponding timestamp to a persistent storage.
public
saveAllowance(Request $request, Action $action, int $allowance, int $timestamp) : mixed