newclass / claudo
The semaphore system for php.
Installs: 1 687
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.0
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2025-02-17 00:18:16 UTC
README
What is Claudo?
Claudo is a PHP semaphore system. Helper for async execute code.
Installation
The best way to install is to use the composer by command:
composer require newclass/claudo
composer install
Use example
use Claudo\Semaphore;
use Claudo\SemaphoreBatch;
$semaphoreBatch = new SemaphoreBatch();
$semaphoreBatch->add(new Semaphore('test1', '.'));
$semaphoreBatch->add(new Semaphore('test2'));
$result = $semaphoreBatch->synchronize(function (Semaphore $semaphore) {
$var = $semaphore->get('var', null);
if (!$var) {
$var = 0;
}
++$var;
$semaphore->set('var', $var);
return sprintf('finish: %s, result: %d',$semaphore->getName(),$var);
});
echo $result;