PHP code example of signe / redlock-php

1. Go to this page and download the library: Download signe/redlock-php 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/ */

    

signe / redlock-php example snippets


$server = new \Redis;
$server->connect('127.0.0.1');

$servers = [
    ['127.0.0.1', 6379, 0.01],
    ['127.0.0.1'],
    $server,
];

$redLock = new RedLock($servers);



$lock = $redLock->lock('my_resource_name', 1000);


Array
(
    [validity] => 9897.3020019531
    [resource] => my_resource_name
    [token] => 53771bfa1e775
)

    $redLock->unlock($lock)