PHP code example of wpjscc / reactphp-request-limiter
1. Go to this page and download the library: Download wpjscc/reactphp-request-limiter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wpjscc / reactphp-request-limiter example snippets
use Wpjscc\Request\Limiter;
// 10 request per second, when third parameter is true, it will be queue to handle
$limiter = new Limiter(10, 1000, false);
$limiter->on('data', function ($key, $data) {
echo $key . ' is completed ' . PHP_EOL;
});
for ($i=0; $i < 100; $i++) {
$limiter->addHandle($i, function () {
return \React\Promise\resolve(true);
});
}