bogkov / concurrency-limit
此组件提供了在服务器上实现并发限制的功能
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-09-29 04:25:50 UTC
README
并发限制
此组件提供了在服务器上实现并发限制的功能
安装
此包可以作为Composer依赖安装 bogkov/concurrency-limit
composer require bogkov/concurrency-limit
使用方法
<?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; }