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 ();