RateLimiter
Less than 1 minute
RateLimiter
Class RateLimiter.
This class is responsible for rate limiting HTTP requests.
Properties
backend
private Backend $backendwindowLength
private int $windowLengthrequestLimit
private int $requestLimitrequestMinimumPeriod
private int $requestMinimumPeriodheaders
private array $headers = array (
'X-RateLimit-Window' => '{{window}}',
'X-RateLimit-Limit' => '{{limit}}',
'X-RateLimit-Attempts' => '{{attempts}}',
'X-RateLimit-Remaining' => '{{remaining}}',
'X-RateLimit-Identifier' => '{{identifier}}',
'X-RateLimit-Cache' => '{{cache}}',
)Methods
__construct
RateLimiter constructor.
public __construct(array $options, ?Backend $backend): voidParameters
| Parameter | Type | Description |
|---|---|---|
$options | array | the options for the rate limiter |
$backend | Backend | the backend to use for the rate limiter |
getInfo
Retrieves information about a specific identifier.
public getInfo(string $identifier): voidParameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the identifier to retrieve information for |
check
Checks if the given identifier is allowed to proceed based on rate limiting rules.
public check(string $identifier): boolParameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the identifier to check |
delete
Deletes a rate limiter entry identified by the given identifier.
public delete(string $identifier): voidParameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the identifier of the rate limiter entry to delete |
getHeaders
Retrieves the headers for the specified identifier.
public getHeaders(string $identifier): voidParameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the identifier for the headers |
getLastRequestTime
public getLastRequestTime(string $identifier): intParameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string |
Generated by Hazaar API Doc Generator on Mon, 27 Oct 2025 13:01:29 +0000