PHP code example of bogkov / concurrency-limit
1. Go to this page and download the library: Download bogkov/concurrency-limit 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/ */
bogkov / concurrency-limit example snippets
$provider = new \Bogkov\ConcurrencyLimit\Provider\Cache(new \Doctrine\Common\Cache\ArrayCache());
$handler = new \Bogkov\ConcurrencyLimit\Handler($provider);
$key = 'some-handle-key';
$limit = 1;
if (true === $handler->start($key, $limit)) {
echo 'continue process' . PHP_EOL;
$handler->end($key);
} else {
echo 'concurrency limit exceeded' . PHP_EOL;
}