[feature/memcache-multi-server] Changing format for multiple memcache hosts. Fixing code style issues in changes.

Host and ports are now represented like this in config:
host1/port1,host2/port2,host3/port3
This commit is contained in:
mrkurt 2010-03-18 06:08:24 -05:00 committed by Nils Adermann
parent 559313eda6
commit c57c1f3fc6

View file

@ -37,9 +37,10 @@ if (!defined('PHPBB_ACM_MEMCACHE_HOST'))
define('PHPBB_ACM_MEMCACHE_HOST', 'localhost'); define('PHPBB_ACM_MEMCACHE_HOST', 'localhost');
} }
if (!defined('PHPBB_ACM_MEMCACHE')){ if (!defined('PHPBB_ACM_MEMCACHE'))
//can define multiple servers with host1::port1,host2::port2 format {
define('PHPBB_ACM_MEMCACHE', PHPBB_ACM_MEMCACHE_HOST . '::' . PHPBB_ACM_MEMCACHE_PORT); //can define multiple servers with host1/port1,host2/port2 format
define('PHPBB_ACM_MEMCACHE', PHPBB_ACM_MEMCACHE_HOST . '/' . PHPBB_ACM_MEMCACHE_PORT);
} }
/** /**
@ -59,9 +60,10 @@ class acm extends acm_memory
parent::acm_memory(); parent::acm_memory();
$this->memcache = new Memcache; $this->memcache = new Memcache;
foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u){ foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u)
$parts = explode('::', $u); {
$this->memcache->addServer($parts[0], $parts[1]); $parts = explode('/', $u);
$this->memcache->addServer(trim($parts[0]), trim($parts[1]));
} }
$this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0;
} }