PHP Interface yii\filters\RateLimitInterface

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

Méthodes publiques

Méthode 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 méthode

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
Résultat 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 méthode

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
Résultat 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 méthode

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.