sunaoka / process-guard-php
This library has been designed with the intention of preventing the execution of multiple instances of a script.
v1.0.1
2024-12-13 00:28 UTC
Requires
- php: ^8.0
- psr/log: ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.12 || ^2.0
- phpstan/phpstan-phpunit: ^1.4 || ^2.0
- phpunit/phpunit: ^9.6.20 || ^10.5.30 || ^11.3.1
This package is auto-updated.
Last update: 2024-12-13 00:29:59 UTC
README
This library has been designed with the intention of preventing the execution of multiple instances of a script.
In the event that it is intended for use in batch processing and a script is already running, all subsequent attempts at execution can be terminated until the current process completes.
Installation
composer require sunaoka/process-guard-php
Basic Usage
use Sunaoka\ProcessGuard\Drivers\FileDriver; use Sunaoka\ProcessGuard\LockFactory; $driver = new FileDriver(); $factory = new LockFactory($driver); $lock = $factory->create('Preventing Multiple Instances', ttl: 60.0); if ($lock->acquire() === false) { // already running exit; } // You can do some processing $lock->release();