@@ -84,7 +84,7 @@ {% endif %} -
{%- for key, value in collector.options[name] %} {{- '%-25s'|format(key~':') }} {{ value }}{{ "\n" -}} diff --git a/Session/Storage/LockingSessionHandler.php b/Session/Storage/LockingSessionHandler.php index b4e7ac9..2cac0af 100644 --- a/Session/Storage/LockingSessionHandler.php +++ b/Session/Storage/LockingSessionHandler.php @@ -4,10 +4,10 @@ /** * LockingSessionHandler. * - * Memcached based session storage handler based on the Memcached class - * provided by the PHP memcached extension with added locking support. + * Memcache based session storage handler based on the MemcachePool class + * provided by the PHP memcache extension with added locking support. * - * @see http://php.net/memcached + * @see http://php.net/memcache * * @author Maurits van der Schee*/ @@ -45,9 +45,9 @@ class LockingSessionHandler implements \SessionHandlerInterface private $lockMaxWait; /** - * @var \Memcached Memcached driver. + * @var \MemcachePool Memcache driver. */ - private $memcached; + private $memcache; /** * @var integer Time to live in seconds @@ -63,17 +63,17 @@ class LockingSessionHandler implements \SessionHandlerInterface * Constructor. * * List of available options: - * * prefix: The prefix to use for the memcached keys in order to avoid collision + * * prefix: The prefix to use for the memcache keys in order to avoid collision * * expiretime: The time to live in seconds * - * @param \Memcached $memcached A \Memcached instance - * @param array $options An associative array of Memcached options + * @param \MemcachePool $memcache A \MemcachePool instance + * @param array $options An associative array of Memcache options * * @throws \InvalidArgumentException When unsupported options are passed */ - public function __construct(\Memcached $memcached, array $options = array()) + public function __construct(\MemcachePool $memcache, array $options = array()) { - $this->memcached = $memcached; + $this->memcache = $memcache; if ($diff = array_diff(array_keys($options), array('prefix', 'expiretime', 'locking', 'spin_lock_wait', 'lock_max_wait'))) { throw new \InvalidArgumentException(sprintf( @@ -108,15 +108,11 @@ private function lockSession($sessionId) $this->lockKey = $sessionId.'.lock'; for ($i=0;$i<$attempts;$i++) { - $success = $this->memcached->add($this->prefix.$this->lockKey, '1', $this->lockMaxWait+1); + $success = $this->memcache->add($this->prefix.$this->lockKey, '1', null, $this->lockMaxWait+1); if ($success) { $this->locked = true; return true; } - $status = $this->memcached->getResultCode(); - if ($status != \Memcached::RES_NOTSTORED && $status != \Memcached::RES_DATA_EXISTS) { - break; - } usleep($this->spinLockWait); } @@ -125,7 +121,7 @@ private function lockSession($sessionId) private function unlockSession() { - $this->memcached->delete($this->prefix.$this->lockKey); + $this->memcache->delete($this->prefix.$this->lockKey); $this->locked = false; } @@ -155,7 +151,7 @@ public function read($sessionId) } } - return $this->memcached->get($this->prefix.$sessionId) ?: ''; + return $this->memcache->get($this->prefix.$sessionId) ?: ''; } /** @@ -171,7 +167,7 @@ public function write($sessionId, $data) } } - return $this->memcached->set($this->prefix.$sessionId, $data, time() + $this->ttl); + return $this->memcache->set($this->prefix.$sessionId, $data, null, $this->ttl); } /** @@ -179,7 +175,7 @@ public function write($sessionId, $data) */ public function destroy($sessionId) { - $this->memcached->delete($this->prefix.$sessionId); + $this->memcache->delete($this->prefix.$sessionId); $this->close(); return true; } @@ -189,7 +185,7 @@ public function destroy($sessionId) */ public function gc($lifetime) { - // not required here because memcached will auto expire the records anyhow. + // not required here because memcache will auto expire the records anyhow. return true; } diff --git a/Tests/Cache/AntiDogPileMemcacheTest.php b/Tests/Cache/AntiDogPileMemcacheTest.php index 4b4a4a6..9fde309 100644 --- a/Tests/Cache/AntiDogPileMemcacheTest.php +++ b/Tests/Cache/AntiDogPileMemcacheTest.php @@ -14,7 +14,7 @@ class AntiDogPileMemcacheTest extends \PHPUnit_Framework_TestCase { public function testConstructAndInterfaces() { - $cache = new AntiDogPileMemcache('foo'); + $cache = new AntiDogPileMemcache('foo',array()); $this->assertInstanceOf('\Lsw\MemcacheBundle\Cache\LoggingMemcache', $cache); } diff --git a/Tests/Cache/DogPileTest_.php b/Tests/Cache/DogPileTest_.php index 00ea3fa..ba1ddaf 100644 --- a/Tests/Cache/DogPileTest_.php +++ b/Tests/Cache/DogPileTest_.php @@ -23,8 +23,8 @@ public function testDogPile() } $c = 10; - $m = new AntiDogPileMemcache(false); - $m->addServer('localhost', 11211); + $m = new AntiDogPileMemcache(false,array()); + $m->addServer('localhost', 11212, 0); if ($t==1) { echo "THREAD | SECOND | STATUS\n"; } diff --git a/Tests/Cache/LoggingMemcacheTest.php b/Tests/Cache/LoggingMemcacheTest.php index 00391ab..85069f4 100644 --- a/Tests/Cache/LoggingMemcacheTest.php +++ b/Tests/Cache/LoggingMemcacheTest.php @@ -14,9 +14,9 @@ class LoggingMemcacheTest extends \PHPUnit_Framework_TestCase { public function testConstructAndInterfaces() { - $cache = new LoggingMemcache('foo'); + $cache = new LoggingMemcache('foo',array()); - $this->assertInstanceOf('\Memcached', $cache); + $this->assertInstanceOf('\MemcachePool', $cache); $this->assertInstanceOf('\Lsw\MemcacheBundle\Cache\MemcacheInterface', $cache); $this->assertInstanceOf('\Lsw\MemcacheBundle\Cache\LoggingMemcacheInterface', $cache); } @@ -28,7 +28,7 @@ public function testOpenPort() public function testGet() { - $m = new LoggingMemcache(false); + $m = new LoggingMemcache(false,array()); $m->addServer('localhost', 11211); $m->set('key', 'value'); $value = $m->get('key'); diff --git a/Tests/Cache/MemcacheInterfaceTest.php b/Tests/Cache/MemcacheInterfaceTest.php index 9a7902f..f3e7fb4 100644 --- a/Tests/Cache/MemcacheInterfaceTest.php +++ b/Tests/Cache/MemcacheInterfaceTest.php @@ -28,42 +28,26 @@ function (\ReflectionMethod $method) { private function getDefaultMethods() { return array( - 'get', - 'getByKey', - 'getMulti', - 'getMultiByKey', - 'getDelayed', - 'getDelayedByKey', - 'fetch', - 'fetchAll', - 'set', - 'setByKey', - 'setMulti', - 'setMultiByKey', - 'cas', - 'casByKey', - 'add', - 'addByKey', - 'append', - 'appendByKey', - 'prepend', - 'prependByKey', - 'replace', - 'replaceByKey', - 'delete', - 'deleteByKey', - 'increment', - 'decrement', - 'getOption', - 'setOption', - 'addServer', - 'addServers', - 'getServerList', - 'getServerByKey', - 'flush', - 'getStats', - 'getResultCode', - 'getResultMessage', + 'setFailureCallback', + 'getServerStatus', + 'getVersion', + 'add', + 'set', + 'replace', + 'cas', + 'prepend', + 'get', + 'getStats', + 'getExtendedStats', + 'setCompressThreshold', + 'delete', + 'increment', + 'decrement', + 'close', + 'flush', + 'addServer', + 'connect', + 'findServer', ); } }