RateLimiter
RateLimiter
Class RateLimiter.
class RateLimiterThis class is responsible for rate limiting HTTP requests.
Properties
backend
The backend implementation used for rate limiting.
private Backend $backendType: Hazaar\Util\RateLimiter\Backend
windowLength
The length of the rate limiting window in seconds.
private int $windowLengthType: int
requestLimit
The maximum number of requests allowed per window.
private int $requestLimitType: int
requestMinimumPeriod
The minimum period (in seconds) between requests.
private int $requestMinimumPeriodType: int
headers
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}}',
)Type: array
Methods
__construct
RateLimiter constructor.
public __construct(Options $options = 'new Options()', ?Backend $backend): voidParameters
| Parameter | Type | Description |
|---|---|---|
$options | Hazaar\Util\RateLimiter\Options | the options for the rate limiter |
$backend | Hazaar\Util\RateLimiter\Backend | the backend to use for the rate limiter |
getInfo
Retrieves information about a specific identifier.
public getInfo(string $identifier): arrayReturns: array
Parameters
| 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): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the identifier to check |
delete
Deletes a rate limiter entry identified by the given identifier.
public delete(string $identifier): voidReturns: void
Parameters
| 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): arrayReturns: array
Parameters
| 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): intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the unique identifier for which to get the last request time |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000