Thứ Hai, 23 tháng 5, 2016

RateLimiter control TPS for PHP & Java

Class yii\filters\RateLimiter

Inheritanceyii\filters\RateLimiter » yii\base\ActionFilter » yii\base\Behavior » yii\base\Object
Implementsyii\base\Configurable
Available since version2.0
Source Code https://github.com/yiisoft/yii2/blob/master/framework/filters/RateLimiter.php    
RateLimiter implements a rate limiting algorithm based on the leaky bucket algorithm.
You may use RateLimiter by attaching it as a behavior to a controller or module, like the following,
public function behaviors()
{
    return [
        'rateLimiter' => [
            'class' => \yii\filters\RateLimiter::className(),
        ],
    ];
}
 
 
When the user has exceeded his rate limit, RateLimiter will throw a yii\web\TooManyRequestsHttpException exception.
Note that RateLimiter requires $user to implement the yii\filters\RateLimitInterface. RateLimiter will do nothing if $user is not set or does not implement yii\filters\RateLimitInterface.
 

Không có nhận xét nào:

Đăng nhận xét