RedisStore
class RedisStore implements Store
Constants
| private FIXED_WINDOW_FUNCTIONS |
|
| private CALENDAR_WINDOW_FUNCTIONS |
|
| private SLIDING_WINDOW_FUNCTIONS |
|
| private LEAKY_BUCKET_FUNCTIONS |
|
| private CONSUME_MANY_SCRIPT |
|
| private SCALAR_ADMISSION_SCRIPT |
|
| private FIXED_WINDOW_SCRIPT |
|
| private CALENDAR_WINDOW_SCRIPT |
|
| private SLIDING_WINDOW_SCRIPT |
|
| private LEAKY_BUCKET_SCRIPT |
|
| private BACKOFF_SCRIPT |
|
| private COOLDOWN_SCRIPT |
|
Methods
Consume a group atomically, or inspect then consume on Redis Cluster.
Check distributed keys before consuming them individually.
Atomically extend a cooldown block.
Inspect a policy without mutating its state.
Clear the state for a physical limiter key.
Execute an admission operation, reusing a held connection for Cluster groups.
Return the algorithm, script parameters, and capacity for an admission policy.
Execute an exponential-backoff operation.
Execute a cooldown operation.
Execute a rate limiter script through Redis's SHA cache.
Convert a Redis tuple to an admission result.
Get Redis's epoch microseconds from a stale calendar-window reply, or null for any other reply.
Validate and return a five-integer Redis result tuple.
Details
at line 454
__construct(Factory $redis, string $connection)
Create a new Redis rate limiter store.
at line 463
LimitResult
consume(string $key, AdmissionPolicy $policy)
Atomically consume capacity from an admission policy.
at line 477
array
consumeMany(array $policies)
Consume a group atomically, or inspect then consume on Redis Cluster.
Cluster preflight denials charge nothing. A denial during consumption can leave earlier charges, including when a group repeats a key.
at line 531
protected array
consumeManyOnCluster(RedisConnection $connection, array $policies)
Check distributed keys before consuming them individually.
at line 552
CooldownResult
block(string $key, int $durationMicroseconds)
Atomically extend a cooldown block.
at line 562
LimitResult|BackoffResult|CooldownResult
inspect(string $key, AdmissionPolicy|Backoff|Cooldown $policy)
Inspect a policy without mutating its state.
at line 576
BackoffResult
recordFailure(string $key, Backoff $backoff)
Record a failure against a backoff policy.
at line 584
bool
clear(string $key)
Clear the state for a physical limiter key.
at line 595
protected LimitResult
executeAdmission(string $key, AdmissionPolicy $policy, string $mode, RedisConnection|null $connection = null)
Execute an admission operation, reusing a held connection for Cluster groups.
at line 628
protected array
admissionParameters(AdmissionPolicy $policy, int|null $nowMicroseconds = null)
Return the algorithm, script parameters, and capacity for an admission policy.
A calendar window is calculated at the given epoch microsecond, or at the current time.
at line 655
protected BackoffResult
executeBackoff(string $key, Backoff $backoff, string $mode)
Execute an exponential-backoff operation.
at line 677
protected CooldownResult
executeCooldown(string $key, int $durationMicroseconds, string $mode)
Execute a cooldown operation.
at line 694
protected mixed
execute(string $script, string $key, array $arguments)
Execute a rate limiter script through Redis's SHA cache.
at line 709
protected LimitResult
limitResult(mixed $result, int $expectedLimit)
Convert a Redis tuple to an admission result.
at line 730
protected int|null
staleCalendarTime(mixed $result)
Get Redis's epoch microseconds from a stale calendar-window reply, or null for any other reply.
at line 748
protected array
integerTuple(mixed $result)
Validate and return a five-integer Redis result tuple.