bogkov/concurrency-limit

This component provides the functionality to concurrency limit on server

1.0.0 2017-06-04 22:59 UTC

This package is not auto-updated.

Last update: 2024-04-28 02:00:41 UTC


README

GitHub license Latest Stable Version Minimum PHP Version Build Status codecov Scrutinizer Code Quality

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;
}