PHP Interface yii\filters\RateLimitInterface

Since: 2.0
Author: Qiang Xue ([email protected])
Datei anzeigen Open project: yiisoft/yii2 Interface Usage Examples

Public Methods

Method Description
getRateLimit ( Request $request, Action $action ) : array Returns the maximum number of allowed requests and the window size.
loadAllowance ( Request $request, Action $action ) : array Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
saveAllowance ( Request $request, Action $action, integer $allowance, integer $timestamp ) Saves the number of allowed requests and the corresponding timestamp to a persistent storage.

Method Details

getRateLimit() public method

Returns the maximum number of allowed requests and the window size.
public getRateLimit ( Request $request, Action $action ) : array
$request yii\web\Request the current request
$action yii\base\Action the action to be executed
return array 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() public method

Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
public loadAllowance ( Request $request, Action $action ) : array
$request yii\web\Request the current request
$action yii\base\Action the action to be executed
return array an array of two elements. The first element is the number of allowed requests, and the second element is the corresponding UNIX timestamp.

saveAllowance() public method

Saves the number of allowed requests and the corresponding timestamp to a persistent storage.
public saveAllowance ( Request $request, Action $action, integer $allowance, integer $timestamp )
$request yii\web\Request the current request
$action yii\base\Action the action to be executed
$allowance integer the number of allowed requests remaining.
$timestamp integer the current timestamp.