PHP code example of mmeyer2k / semlock

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

    

mmeyer2k / semlock example snippets


\mmeyer2k\SemLock::synchronize('some_key', function () {
    $x = get_number_from_database();

    $x++;

    sleep(5);

    save_number_to_database($x);
});

$returned = \mmeyer2k\SemLock::synchronize('some_key', function () {
    return 'something';
});

# $returned === 'something'