throttle
1.0.0
与作曲家安装
composer require zeus/throttle设置HTTP请求限制,例如在10分钟内仅100个访问权限,功能强大的Redis处理HTTP请求,您可以轻松地将其集成到所有API或项目中
use Throttle Throttle ;
use Throttle Time ;
$ throttle = new Throttle (
new Time ( 60 , 25 )
);
$ throttle -> commit ();
if ( $ throttle -> isHasAccessLimit ()) {
print ' request can go next ' ;
} else {
print ' max request amount ' ;
}
use Throttle Throttle ;
use Throttle Time ;
use Throttle Redis ;
Redis:: setRedisClient ( new Predis Client ( $ params ));
$ throttle = new Throttle (
new Time ( 60 , 25 )
);
$ throttle -> commit ();
if ( $ throttle -> isHasAccessLimit ()) {
print ' request can go next ' ;
} else {
print ' max request amount ' ;
}获取细节
$ throttle -> getDetail ()-> toArray ();