HumHub Documentation (unofficial)

RateLimitInterface

RateLimitInterface is the interface that may be implemented by an identity object to enforce rate limiting.

Tags
author

Qiang Xue qiang.xue@gmail.com

since
2.0

Table of Contents

Methods

getRateLimit()  : array<string|int, mixed>
Returns the maximum number of allowed requests and the window size.
loadAllowance()  : array<string|int, mixed>
Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
saveAllowance()  : mixed
Saves the number of allowed requests and the corresponding timestamp to a persistent storage.

Methods

getRateLimit()

Returns the maximum number of allowed requests and the window size.

public getRateLimit(Request $request, Action $action) : array<string|int, mixed>
Parameters
$request : Request

the current request

$action : Action

the action to be executed

Return values
array<string|int, mixed>

an array of two elements. The first element is the maximum number of allowed requests, and the second element is the size of the window in seconds.

loadAllowance()

Loads the number of allowed requests and the corresponding timestamp from a persistent storage.

public loadAllowance(Request $request, Action $action) : array<string|int, mixed>
Parameters
$request : Request

the current request

$action : Action

the action to be executed

Return values
array<string|int, mixed>

an array of two elements. The first element is the number of allowed requests, and the second element is the corresponding UNIX timestamp.

saveAllowance()

Saves the number of allowed requests and the corresponding timestamp to a persistent storage.

public saveAllowance(Request $request, Action $action, int $allowance, int $timestamp) : mixed
Parameters
$request : Request

the current request

$action : Action

the action to be executed

$allowance : int

the number of allowed requests remaining.

$timestamp : int

the current timestamp.


        
On this page

Search results