PHP code example of ingenerator / runsingle

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

    

ingenerator / runsingle example snippets



return Ingenerator\RunSingle\DbDriverFactory::factory(array(
    'dsn'            => 'mysql:host=localhost;dbname=run_single_db',
    'db_user'        => 'root',
    'db_pass'        => '',
    'db_table_name'  => 'locks',
));

$lock_driver = new \Ingenerator\RunSingle\DbDriver;
$lock_id = $lock_driver->get_lock($task_name, $timeout, $garbage_collect);
if ($lock_id) {
// do your stuff
  $lock_driver->release_lock($task_name, $lock_id);
}