yii\filters\RateLimitInterface - Yii2 类参考手册

Interface yii\filters\RateLimitInterface

Available since version2.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

getRateLimit() public abstract method

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.

loadAllowance() public abstract method

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.

saveAllowance() public abstract method

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.