#5767: Multiple Memcache server does not get added
-----------------------------------+----------------------------------------
Reporter: anupom | Type: Bug
Status: new | Priority: High
Milestone: 1.2.x.x | Component: Cache
Version: RC3 | Severity: Normal
Keywords: caching, memcached | Php_version: n/a
Cake_version: 1.2.0.7692 RC3 |
-----------------------------------+----------------------------------------
If multiple memcache servers are added through Cache::config like the
following,
{{{
Cache::config('default', array(
'engine' => 'Memcache', //[required]
'servers' => array(
'127.0.0.1:11211',
'127.0.0.1:11222'
)
));
}}}
Then the first valid server actually gets added to the memcached server
pool. Later ones are ignored. In this case, '127.0.0.1:11211' gets added
and '127.0.0.1:11222'
is ignored.
[[BR]]
Following test case would fail due to this issue,
{{{
function setUp() {
Cache::config('memcache', array('engine'=>'Memcache',
'prefix' => 'cake_',
'servers' => array('127.0.0.1:11211',
'127.0.0.1:11222')));
}
function testMultipleMemcacheServers() {
$Cache =& Cache::getInstance();
$servers =
array_keys($Cache->_Engine['Memcache']->__Memcache->getExtendedStats());
$settings = Cache::settings();
$this->assertEqual($servers, $settings['servers']);
}
}}}
A possible patch can be the following, line 76,
cake/libs/cache/memcache.php
{{{
if (!isset($this->__Memcache)) {
$this->__Memcache =& new Memcache();
$result = false;
foreach ($this->settings['servers'] as $server) {
$parts = explode(':', $server);
$host = $parts[0];
$port = 11211;
if (isset($parts[1])) {
$port = $parts[1];
}
if ($this->__Memcache->addServer($host, $port)) {
$result = true;
}
}
return $result;
}
}}}
If any single server from the $servers array works then
MemcacheEngine::init() should return a true, I guess..
--
Ticket URL: <https://trac.cakephp.org/ticket/5767>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---