Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public function __construct(\Memcached $client, $namespace = '', $defaultLifetim
if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) {
throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
}
if (!$client->getOption(\Memcached::OPT_BINARY_PROTOCOL)) {
throw new CacheException('MemcachedAdapter: "binary_protocol" option must be enabled.');
}
$this->maxIdLength -= strlen($client->getOption(\Memcached::OPT_PREFIX_KEY));

parent::__construct($namespace, $defaultLifetime);
Expand All @@ -67,7 +64,7 @@ public function __construct(\Memcached $client, $namespace = '', $defaultLifetim
*
* @return \Memcached
*
* @throws \ErrorEception When invalid options or servers are provided.
* @throws \ErrorEception When invalid options or servers are provided
*/
public static function createConnection($servers, array $options = array())
{
Expand Down
15 changes: 4 additions & 11 deletions src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function setupBeforeClass()
if (!MemcachedAdapter::isSupported()) {
self::markTestSkipped('Extension memcached >=2.2.0 required.');
}
self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'));
self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false));
self::$client->get('foo');
$code = self::$client->getResultCode();

Expand All @@ -40,7 +40,9 @@ public static function setupBeforeClass()

public function createCachePool($defaultLifetime = 0)
{
return new MemcachedAdapter(self::$client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
$client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')) : self::$client;

return new MemcachedAdapter($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
}

public function testOptions()
Expand Down Expand Up @@ -80,15 +82,6 @@ public function provideBadOptions()
);
}

/**
* @expectedException \Symfony\Component\Cache\Exception\CacheException
* @expectedExceptionMessage MemcachedAdapter: "binary_protocol" option must be enabled.
*/
public function testBinaryProtocol()
{
new MemcachedAdapter(MemcachedAdapter::createConnection(array(), array('binary_protocol' => false)));
}

public function testDefaultOptions()
{
$this->assertTrue(MemcachedAdapter::isSupported());
Expand Down