minor #21268 [Cache] Relax binary-constraint on Memcached connections (nicolas-grekas)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[Cache] Relax binary-constraint on Memcached connections
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
If it's green then it's PSR-6 compliant.
Commits
-------
284d363
[Cache] Relax binary-constraint on Memcached connections
This commit is contained in:
commit
42c3d4fe02
@ -44,9 +44,6 @@ class MemcachedAdapter extends AbstractAdapter
|
||||
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);
|
||||
@ -67,7 +64,7 @@ class MemcachedAdapter extends AbstractAdapter
|
||||
*
|
||||
* @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())
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ class MemcachedAdapterTest extends AdapterTestCase
|
||||
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();
|
||||
|
||||
@ -40,7 +40,9 @@ class MemcachedAdapterTest extends AdapterTestCase
|
||||
|
||||
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()
|
||||
@ -80,15 +82,6 @@ class MemcachedAdapterTest extends AdapterTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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());
|
||||
|
Reference in New Issue
Block a user