1. Go to this page and download the library: Download avtonom/semaphore-bundle 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/ */
avtonom / semaphore-bundle example snippets
$bundles(
...
new Avtonom\SemaphoreBundle\AvtonomSemaphoreBundle(),
new Snc\RedisBundle\SncRedisBundle(),
...
);
php
use Avtonom\SemaphoreBundle\Traits\SemaphoreTrait\SemaphoreTrait;
// or
/** @var $semaphore \Avtonom\Semaphore\Model\SemaphoreManagerInterface */
$semaphore = $container->get('avtonom_semaphore.manager');
$lockKeyStorage = $this->getLockKeyStorage();
$lockKey = [$lockKeyStorage::MY_KEY, $param1, $param2, $paramN];
$this->lockAcquire($lockKey, __METHOD__, 10 /* 10 - if you personal lock expire time in seconds. default 60 */);
// Do something thread-safe
$this->lockRelease($lockKey, __METHOD__);
php
namespace Application\Avtonom\SemaphoreBundle;
use Avtonom\SemaphoreBundle\Model\SemaphoreKeyStorageInterface;
class SemaphoreKeyStorage implements SemaphoreKeyStorageInterface
{
const
MY_KEY = 'M_K_',
MY_OTHER_KEY = 'M_O_K_'
;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.