From 559313eda60459ed7b73e790257321402824d35c Mon Sep 17 00:00:00 2001 From: mrkurt Date: Wed, 17 Mar 2010 06:08:52 -0500 Subject: [PATCH 1/2] [feature/memcache-multi-server] Adding support for multiple memcache servers to acm_memcache.php You can define multiple memcache servers in your config using this format: host::port,host::port,host::port Example: @define(PHPBB_ACM_MEMCACHE, '127.0.0.1::11211,10.0.0.2::11211,memcache1::11211' --- phpBB/includes/acm/acm_memcache.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 52b8832749..5a96509d38 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -37,6 +37,11 @@ if (!defined('PHPBB_ACM_MEMCACHE_HOST')) define('PHPBB_ACM_MEMCACHE_HOST', 'localhost'); } +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); +} + /** * ACM for Memcached * @package acm @@ -54,7 +59,10 @@ class acm extends acm_memory parent::acm_memory(); $this->memcache = new Memcache; - $this->memcache->connect(PHPBB_ACM_MEMCACHE_HOST, PHPBB_ACM_MEMCACHE_PORT); + foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u){ + $parts = explode('::', $u); + $this->memcache->addServer($parts[0], $parts[1]); + } $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; } @@ -125,4 +133,4 @@ class acm extends acm_memory } } -?> \ No newline at end of file +?> From c57c1f3fc606665fad6b31993c4a1481018b0915 Mon Sep 17 00:00:00 2001 From: mrkurt Date: Thu, 18 Mar 2010 06:08:24 -0500 Subject: [PATCH 2/2] [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 --- phpBB/includes/acm/acm_memcache.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 5a96509d38..e54fa36c38 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -37,9 +37,10 @@ if (!defined('PHPBB_ACM_MEMCACHE_HOST')) define('PHPBB_ACM_MEMCACHE_HOST', 'localhost'); } -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); +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); } /** @@ -59,9 +60,10 @@ class acm extends acm_memory parent::acm_memory(); $this->memcache = new Memcache; - foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u){ - $parts = explode('::', $u); - $this->memcache->addServer($parts[0], $parts[1]); + foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u) + { + $parts = explode('/', $u); + $this->memcache->addServer(trim($parts[0]), trim($parts[1])); } $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; }