PHP code example of wyrihaximus / react-mutex-redis
1. Go to this page and download the library: Download wyrihaximus/react-mutex-redis 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/ */
wyrihaximus / react-mutex-redis example snippets
use Clue\React\Redis\Factory;
use RTCKit\React\Redlock\Custodian;
use WyriHaximus\React\Redis\Mutex\Mutex;
$mutex = new Mutex(new Custodian((new Factory())->createLazyClient('redis://localhost:6379/13'))); // Use DB 13 as mutex database
$lock = $mutex->acquire('key', 1.23);
$mutex->release($lock);