Documentation

RateLimiter
in package

FinalYes

Table of Contents

Constants

CACHE_TAG  : mixed = 'rate_limit'

Properties

$key  : string
$maxAttempts  : int
$windowSeconds  : int

Methods

__construct()  : mixed
attempt()  : bool
Check-and-record: records a hit unless already over budget. Returns true when the request is allowed, false when blocked.
attempts()  : int
Number of hits still inside the window.
clear()  : void
Forget every hit for this key.
hit()  : void
Record a single hit. For check-up-front / record-on-failure flows where the check and the record happen at different points (see Mage_Sales_Helper_Guest).
remaining()  : int
Hits left before the next one blocks.
tooManyAttempts()  : bool
True when the key is at or over its budget. Pure read, records nothing.
cacheId()  : string
loadHits()  : array<int, int>

Constants

Properties

Methods

__construct()

public __construct(string $key, int $maxAttempts, int $windowSeconds) : mixed
Parameters
$key : string
$maxAttempts : int
$windowSeconds : int

attempt()

Check-and-record: records a hit unless already over budget. Returns true when the request is allowed, false when blocked.

public attempt() : bool
Return values
bool

attempts()

Number of hits still inside the window.

public attempts() : int
Return values
int

clear()

Forget every hit for this key.

public clear() : void

hit()

Record a single hit. For check-up-front / record-on-failure flows where the check and the record happen at different points (see Mage_Sales_Helper_Guest).

public hit() : void

remaining()

Hits left before the next one blocks.

public remaining() : int
Return values
int

tooManyAttempts()

True when the key is at or over its budget. Pure read, records nothing.

public tooManyAttempts() : bool
Return values
bool

cacheId()

private cacheId() : string
Return values
string

loadHits()

private loadHits() : array<int, int>
Return values
array<int, int>
On this page

Search results