Interface yii\filters\RateLimitInterface
| Available since version | 2.0 |
|---|
RateLimitInterface is the interface that may be implemented by an identity object to enforce rate limiting.
Public Methods
隐藏继承的方法 Hide inherited methods
| 方法 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 |
方法详情 Method Details
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. |