Skip to content

Commit

Permalink
bug #27299 [Cache] memcache connect should not add duplicate entries …
Browse files Browse the repository at this point in the history
…on sequential calls
  • Loading branch information
Aleksey Prilipko authored and nicolas-grekas committed Jun 4, 2018
1 parent 13be093 commit af06990
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Expand Up @@ -45,6 +45,15 @@ public function createSimpleCache($defaultLifetime = 0)
return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
}

public function testCreatePersistentConnectionShouldNotDupServerList()
{
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('persistent_id' => 'persistent'));
$this->assertCount(1, $instance->getServerList());

$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('persistent_id' => 'persistent'));
$this->assertCount(1, $instance->getServerList());
}

public function testOptions()
{
$client = MemcachedCache::createConnection(array(), array(
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Cache/Traits/MemcachedTrait.php
Expand Up @@ -169,12 +169,12 @@ public static function createConnection($servers, array $options = array())
}

if ($oldServers !== $newServers) {
// before resetting, ensure $servers is valid
$client->addServers($servers);
$client->resetServerList();
$client->addServers($servers);
}
} else {
$client->addServers($servers);
}
$client->addServers($servers);

if (null !== $username || null !== $password) {
if (!method_exists($client, 'setSaslAuthData')) {
Expand Down

0 comments on commit af06990

Please sign in to comment.