rackbeat/php-throttler

通过每秒X次执行来限制PHP函数调用和迭代运行。

0.9.2 2020-01-27 10:45 UTC

This package is auto-updated.

Last update: 2024-08-27 21:23:22 UTC


README

Rackbeat throttler
限制PHP操作,使其在指定时间段内只能运行一定次数。
特别适用于避免速率限制、高CPU使用率或对你的服务(数据库等)进行DOS攻击。

Build Status Coverage Total Downloads Latest Stable Version License

安装

只需使用composer,然后就可以开始了!

composer require rackbeat/php-throttler

使用方法

基本示例

use Rackbeat\Throttler\Throttler;

Throttler::make( range(1,100) )->allow(10)->every(1)->run( function($value, $key) {
    // do something with $value
} );

需求

  • PHP >= 7.3