SwooleStore
class SwooleStore implements Store
Traits
Methods
Calculate an admission decision and update accepted state values.
Calculate ordered group decisions against staged state.
Calculate a non-mutating policy inspection.
Calculate a cooldown extension and update its expiry.
Calculate a failure transition and update its state values.
Get the current epoch time in microseconds.
Create a new Swoole rate limiter store.
Consume all policies while holding their shared table locks.
Atomically extend a cooldown block.
Inspect a policy without mutating its state.
Clear the state for a physical limiter key.
Prune every expired entry.
Prune expired entries and report table pressure.
Get and validate numeric state for a physical limiter key.
Write numeric state for a physical limiter key.
Report exhausted table headroom after periodic pruning.
Details
in
CalculatesRateLimits at line 27
protected LimitResult
calculateConsume(AdmissionPolicy $policy, int $now, int $value, int $secondaryValue, int $expiresAt)
Calculate an admission decision and update accepted state values.
in
CalculatesRateLimits at line 73
protected array
calculateMany(array $policies, int $now, array $states)
Calculate ordered group decisions against staged state.
in
CalculatesRateLimits at line 118
protected LimitResult|BackoffResult|CooldownResult
calculateInspection(AdmissionPolicy|Backoff|Cooldown $policy, int $now, int $value, int $secondaryValue, int $expiresAt)
Calculate a non-mutating policy inspection.
in
CalculatesRateLimits at line 172
protected CooldownResult
calculateCooldownBlock(int $durationMicroseconds, int $now, int $value, int $secondaryValue, int $expiresAt)
Calculate a cooldown extension and update its expiry.
in
CalculatesRateLimits at line 190
protected BackoffResult
calculateFailure(Backoff $backoff, int $now, int $value, int $secondaryValue, int $expiresAt)
Calculate a failure transition and update its state values.
in
CalculatesRateLimits at line 638
protected int
currentTimeInMicroseconds()
Get the current epoch time in microseconds.
at line 22
__construct(TableState $state, float $memoryLimitBuffer, LoggerInterface $logger)
Create a new Swoole rate limiter store.
at line 37
LimitResult
consume(string $key, AdmissionPolicy $policy)
Atomically consume capacity from an admission policy.
at line 84
array
consumeMany(array $policies)
Consume all policies while holding their shared table locks.
at line 148
CooldownResult
block(string $key, int $durationMicroseconds)
Atomically extend a cooldown block.
at line 190
LimitResult|BackoffResult|CooldownResult
inspect(string $key, AdmissionPolicy|Backoff|Cooldown $policy)
Inspect a policy without mutating its state.
at line 210
BackoffResult
recordFailure(string $key, Backoff $backoff)
Record a failure against a backoff policy.
at line 250
bool
clear(string $key)
Clear the state for a physical limiter key.
at line 261
int
pruneExpiredRows()
Prune every expired entry.
at line 297
int
maintain()
Prune expired entries and report table pressure.
at line 310
protected array
storedState(string $key)
Get and validate numeric state for a physical limiter key.
at line 336
protected bool
writeState(string $key, int $value, int $secondaryValue, int $expiresAt)
Write numeric state for a physical limiter key.
at line 348
protected void
reportTablePressure()
Report exhausted table headroom after periodic pruning.