Interface yii\filters\RateLimitInterface
| 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.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getRateLimit() | Returns the maximum number of allowed requests and the window size. | yii\ |
| loadAllowance() | Loads the number of allowed requests and the corresponding timestamp from a persistent storage. | yii\ |
| saveAllowance() | Saves the number of allowed requests and the corresponding timestamp to a persistent storage. | yii\ |
Method Details
Returns the maximum number of allowed requests and the window size.
| public abstract array getRateLimit ( yii\ | ||
| $request | yii\ |
The current request |
| $action | yii\ |
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. |
|---|---|---|
public function getRateLimit($request, $action);
Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
| public abstract array loadAllowance ( yii\ | ||
| $request | yii\ |
The current request |
| $action | yii\ |
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. |
|---|---|---|
public function loadAllowance($request, $action);
Saves the number of allowed requests and the corresponding timestamp to a persistent storage.
| public abstract mixed saveAllowance ( yii\ | ||
| $request | yii\ |
The current request |
| $action | yii\ |
The action to be executed |
| $allowance | integer |
The number of allowed requests remaining. |
| $timestamp | integer |
The current timestamp. |
public function saveAllowance($request, $action, $allowance, $timestamp);
User Contributed Notes
Leave a comment
Join the conversation to share a note.