PHP code example of mmdtl / autolock

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

    

mmdtl / autolock example snippets



$pool = new \AutoLock\Pool(array(
    '192.168.1.1:6379',
    '192.168.1.2:6379',
    '192.168.1.3:6379',
),new \AutoLock\Drivers\PHPRedis());

$manager = new \AutoLock\Manager($pool);



$lock = $manager->lock('distributed_lock',1000);;



$status = $lock->isExpired();
//$status will be true if the lock is expired or it will be false
$status = $lock->isExpired(3600 * 1000);
//$status will be true if the lock will be expired after 3600 seconds or it will be false


    $lock->unlock($lock)