File
File
Rate limiter backend using file-based storage.
class File extends \Hazaar\Util\RateLimiter\BackendExtends: Hazaar\Util\RateLimiter\Backend
This backend implementation uses a BTree database to store and manage rate limiting data. It supports configurable file paths and compaction intervals for efficient storage management.
Properties
db
The BTree database instance used for storing rate limiter data.
private BTree $dbType: Hazaar\Util\BTree
index
private array $indexType: array
created
public int $createdType: int
compactInterval
The interval (in seconds) after which the database should be compacted.
private int $compactInterval = 3600Type: int
Methods
__construct
File rate limiter constructor.
public __construct(array|Options $options): voidParameters
| Parameter | Type | Description |
|---|---|---|
$options | array | Hazaar\Util\RateLimiter\Backend\File\Options |
shutdown
Performs shutdown operations for the rate limiter backend.
public shutdown(): voidReturns: void
This method saves any updated rate limit information to the database and, if the compact interval has elapsed since creation, compacts the database to optimize storage.
check
Checks and updates the rate limit information for a given identifier.
public check(string $identifier): arrayReturns: array
Retrieves the current rate limit data for the specified identifier, appends the current timestamp to the log, updates the internal index, and returns the updated information.
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the unique identifier to check and update rate limit information for |
get
Retrieves and updates the rate limit information for a given identifier.
public get(string $identifier): arrayReturns: array
This method fetches the rate limit log for the specified identifier from the database. It removes any log entries that are outside the configured time window (windowLength). If no log exists for the identifier, it initializes an empty log.
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the unique identifier for which to retrieve rate limit information |
remove
Removes the rate limiter entry associated with the given identifier.
public remove(string $identifier): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the unique identifier for the rate limiter entry to remove |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000