rackbeat / php-throttler
Throttle PHP function calls and iteration runs by X executions per second.
Installs: 23 771
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.3
Requires (Dev)
- php-coveralls/php-coveralls: ^1.0
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-10-27 21:36:20 UTC
README
Throttle PHP actions to only run a set amount of times within a given timeframe.
Especially useful to avoid rate limiting, high CPU usage or DOS'ing your own services (database etc.)
Installation
You just require using composer and you're good to go!
composer require rackbeat/php-throttler
Usage
Basic example
use Rackbeat\Throttler\Throttler; Throttler::make( range(1,100) )->allow(10)->every(1)->run( function($value, $key) { // do something with $value } );
Requirements
- PHP >= 7.3