8000 bug #27299 [Cache] memcache connect should not add duplicate entries … · symfony/symfony@af06990 · GitHub
[go: up one dir, main page]

Skip to content

Commit af06990

Browse files
Aleksey Prilipkonicolas-grekas
Aleksey Prilipko
authored andcommitted
bug #27299 [Cache] memcache connect should not add duplicate entries on sequential calls
1 parent 13be093 commit af06990

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ public function createSimpleCache($defaultLifetime = 0)
4545
return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
4646
}
4747

48+
public function testCreatePersistentConnectionShouldNotDupServerList()
49+
{
50+
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('persistent_id' => 'persistent'));
51+
$this->assertCount(1, $instance->getServerList());
52+
53+
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('persistent_id' => 'persistent'));
54+
$this->assertCount(1, $instance->getServerList());
55+
}
56+
4857
public function testOptions()
4958
{
5059
$client = MemcachedCache::createConnection(array(), array(

src/Symfony/Component/Cache/Traits/MemcachedTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ public static function createConnection($servers, array $options = array())
169169
}
170170

171171
if ($oldServers !== $newServers) {
172-
// before resetting, ensure $servers is valid
173-
$client->addServers($servers);
174172
$client->resetServerList();
173+
$client->addServers($servers);
175174
}
175+
} else {
176+
$client->addServers($servers);
176177
}
177-
$client->addServers($servers);
178178

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

0 commit comments

Comments
 (0)
0