Available since version | 2.0 |
---|---|
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/filters/RateLimitInterface.php |
RateLimitInterface is the interface that may be implemented by an identity object to enforce rate limiting.
Method | Description | Defined By |
---|---|---|
getRateLimit() | Returns the maximum number of allowed requests and the window size. | yii\filters\RateLimitInterface |
loadAllowance() | Loads the number of allowed requests and the corresponding timestamp from a persistent storage. | yii\filters\RateLimitInterface |
saveAllowance() | Saves the number of allowed requests and the corresponding timestamp to a persistent storage. | yii\filters\RateLimitInterface |
Returns the maximum number of allowed requests and the window size.
public abstract array getRateLimit ( $request, $action ) | ||
---|---|---|
$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. |
Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
public abstract array loadAllowance ( $request, $action ) | ||
---|---|---|
$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. |
Saves the number of allowed requests and the corresponding timestamp to a persistent storage.
public abstract void saveAllowance ( $request, $action, $allowance, $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. |
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-filters-ratelimitinterface.html