Permalink
Browse files

[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'
  • Loading branch information...
1 parent 10f81ee commit 559313eda60459ed7b73e790257321402824d35c @mrkurt mrkurt committed with naderman Mar 17, 2010
Showing with 10 additions and 2 deletions.
  1. +10 −2 phpBB/includes/acm/acm_memcache.php
@@ -37,6 +37,11 @@
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 @@ function acm()
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 @@ function _delete($var)
}
}
-?>
+?>

0 comments on commit 559313e

Please sign in to comment.