PHP code example of ivopetkov / lock

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

    

ivopetkov / lock example snippets



voPetkov\Lock;

Lock::acquire('lock1'); // Acquires a lock and pauses other applications/instances/processes until the lock is released.
// Do something awesome
Lock::release('lock1'); // Releases the acquired lock.

Lock::setDefaultLockTimeout(2.5);

Lock::setLocksDir('/some/other/temp/dir/');

Lock::setKeyPrefix('app1');