PHP code example of roadrunner / symfony-lock-driver
1. Go to this page and download the library: Download roadrunner/symfony-lock-driver library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
roadrunner / symfony-lock-driver example snippets
use RoadRunner\Lock\Lock;
use Spiral\Goridge\RPC\RPC;
use Spiral\RoadRunner\Symfony\Lock\RoadRunnerStore;
use Symfony\Component\Lock\LockFactory;
eateLock('invoice-42');
if ($invoiceLock->acquire()) {
try {
// ... critical section
} finally {
$invoiceLock->release();
}
}
// Wait up to 5 seconds for the lock, and hold it for at most 30 seconds.
$store = (new RoadRunnerStore($lock))->withTtl(ttl: 30.0, waitTtl: 5.0);