DBI
DBI
Rate limiter backend using a database interface (DBI).
class DBI extends \Hazaar\Util\RateLimiter\Backend\BackendThis backend implementation uses a database adapter to store and manage rate limiting data. It supports configurable options for database connection and event logging.
Properties
dbi
The database adapter instance used for storing rate limiter data.
private Adapter $dbiMethods
__construct
Constructs a new instance of the DBI rate limiter backend.
public __construct(array $options): voidInitializes the database adapter using the provided options.
Parameters
| Parameter | Type | Description |
|---|---|---|
$options | array | configuration options for the database adapter |
check
Checks the rate limit status for a given identifier.
public check(string $identifier): voidRetrieves the current rate limit information for the specified identifier, logs a check event in the 'rate_limit_log' table, and appends the event time to the log if the insertion is successful.
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the unique identifier to check the rate limit for |
get
Retrieves rate limiting information for a given identifier.
public get(string $identifier): voidThis method queries the 'rate_limit_log' table for entries associated with the specified identifier within the configured time window. It returns an array containing:
- 'log': An array of UNIX timestamps for each relevant event.
- 'last': The timestamp of the last event (default 0).
- 'result': A boolean indicating the result of the rate limit check (default false).
- 'last_result': A boolean indicating the result of the last rate limit check (default false).
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the unique identifier for which to retrieve rate limit data |
remove
Removes rate limiting information for the specified identifier.
public remove(string $identifier): voidThis method should remove all rate limit log entries associated with the given identifier from the database. (Implementation required.)
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | string | the identifier for which to remove rate limit information |
shutdown
Persists or finalizes rate limiter data in the database.
public shutdown(): voidThis method should be called during shutdown to ensure all rate limiter information is properly saved or finalized in the database. (Implementation required.)
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000