RateLimiter
About 1 min
RateLimiter
Class RateLimiter.
class RateLimiterThis class is responsible for rate limiting HTTP requests.
Properties
backend
The backend implementation used for rate limiting.
private Backend $backendwindowLength
The length of the rate limiting window in seconds.
private int $windowLengthrequestLimit
The maximum number of requests allowed per window.
private int $requestLimitrequestMinimumPeriod
The minimum period (in seconds) between requests.
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
Retrieves the timestamp of the last request made by the specified identifier.
public getLastRequestTime(string $identifier): intParameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the unique identifier for which to get the last request time |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000