bogkov / concurrency-limit
This component provides the functionality to concurrency limit on server
1.0.0
2017-06-04 22:59 UTC
Requires
- php: ^7.0
- doctrine/cache: ^1.6
Requires (Dev)
- phpunit/phpunit: ^6.2
This package is not auto-updated.
Last update: 2024-11-10 05:14:11 UTC
README
Concurrency Limit
This component provides the functionality to concurrency limit on server
Installation
This package can be installed as a Composer dependency bogkov/concurrency-limit
composer require bogkov/concurrency-limit
Usage
<?php $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; }