1. Go to this page and download the library: Download pedromazala/semaphore 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/ */
pedromazala / semaphore example snippets
$adapter = new \Millwright\Semaphore\Adapter\ApcAdapter;
$semaphore = new \Millwright\Semaphore\Model\SemaphoreManager($adapter);
$ttl = 60; // Time in seconds, used, if script dies and release never called.
$handle = $semaphore->acquire('lock key', $ttl);
// Do something thread-safe
$semaphore->release($handle);