Cache
Less than 1 minute
Cache
- Full name:
\Hazaar\RateLimiter\Backend\Cache
- Parent class:
\Hazaar\RateLimiter\Backend
Properties
cache
private \Hazaar\Cache $cache
prefix
private string $prefix
index
private array<string,array> $index
Methods
__construct
Cache rate limiter constructor.
public __construct(array $options = []): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$options | array | the options for the cache |
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 |
getKey
Get the key for rate limiting based on the provided identifier.
private getKey(string $identifier): string
Parameters:
Parameter | Type | Description |
---|---|---|
$identifier | string | the identifier used for rate limiting |
Return Value:
the key for rate limiting
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