for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Mutex Library.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AMF\Mutex\Adapter;
use AMF\Mutex\MutexInterface;
/**
* Mutex for memcached.
* @author Amine Fattouch <[email protected]>
class MemcachedMutex implements MutexInterface
{
* @var \Memcached
protected $memcached;
* Constructor class.
* @param \Memcached $memcached
public function __construct(\Memcached $memcached)
$this->memcached = $memcached;
}
* {@inheritdoc}
public function acquire($key, $ttl)
$acquired = $this->memcached->add($key, true, $ttl);
return ($acquired === true) ? $key: null;
public function release($key)
return $this->memcached->delete($key);