# 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

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

Hide inherited methods

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.

Source code

                    public function getRateLimit($request, $action);

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.

Source code

                    public function loadAllowance($request, $action);

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.

Source code

                    public function saveAllowance($request, $action, $allowance, $timestamp);