File
Less than 1 minute
File
- Full name:
\Hazaar\RateLimiter\Backend\File
- Parent class:
\Hazaar\RateLimiter\Backend
Properties
db
private \Hazaar\File\BTree $db
index
private array<string,array> $index
created
private ?int $created
compactInterval
private int $compactInterval
Methods
__construct
File rate limiter constructor.
public __construct(array $options = []): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$options | array | the options for the file |
shutdown
Shutdown the rate limiter backend a commit any changes.
public shutdown(): void
check
Retrieves the rate limit information for the specified identifier and adds the current timestamp to the log.
public check(string $identifier): array{log: int[], last: int, result?: bool, last_result?: bool}
Parameters:
Parameter | Type | Description |
---|---|---|
$identifier | string | the identifier for which to retrieve the rate limit information |
Return Value:
the rate limit information for the specified identifier
get
Retrieves the rate limit information for the specified identifier without adding the current timestamp to the log.
public get(string $identifier): array{log: int[], last: int, result?: bool, last_result?: bool}
Parameters:
Parameter | Type | Description |
---|---|---|
$identifier | string | the identifier for which to retrieve the rate limit information |
Return Value:
the rate limit information for the specified identifier
remove
Removes the rate limit information for the specified identifier.
public remove(string $identifier): void
Parameters:
Parameter | Type | Description |
---|---|---|
$identifier | string | the identifier for which to remove the rate limit information |
Inherited methods
__destruct
public __destruct(): mixed
setWindowLength
public setWindowLength(int $windowLength): void
Parameters:
Parameter | Type | Description |
---|---|---|
$windowLength | int |
commit
public commit(): void
Automatically generated on 2024-11-14