Add support for multiple Memcached servers

- Updated htconfig documentation
This commit is contained in:
Hypolite Petovan 2018-03-04 23:28:49 -05:00
parent 95752b79e8
commit 059b1f63f8
3 changed files with 8 additions and 8 deletions

View file

@ -62,8 +62,7 @@ Example: To set the automatic database cleanup process add this line to your .ht
* **cache_driver** ([database]|memcache|memcached) - Whether to use Memcache or Memcached to store temporary cache
* **memcache_host** - Host name of the memcache daemon. Default is '127.0.0.1'.
* **memcache_port** - Port number of the memcache daemon. Default is 11211.
* **memcached_host** - Host name of the memcached daemon. Default is '127.0.0.1'.
* **memcached_port** - Port number of the memcached daemon. Default is 11211.
* **memcached_hosts** - Array of Memcached servers info [host, port(, weight)]. Default is [['127.0.0.1', 11211]]
* **no_count** (Boolean) - Don't do count calculations (currently only when showing albums)
* **no_oembed** (Boolean) - Don't use OEmbed to fetch more information about a link.
* **no_smilies** (Boolean) - Don't show smilies.

View file

@ -36,10 +36,9 @@ class Cache extends \Friendica\BaseObject
self::$driver = new Cache\MemcacheCacheDriver($memcache_host, $memcache_port);
break;
case 'memcached':
$memcached_host = Config::get('system', 'memcached_host', '127.0.0.1');
$memcached_port = Config::get('system', 'memcached_port', 11211);
$memcached_hosts = Config::get('system', 'memcached_hosts', [['127.0.0.1', 11211]]);
self::$driver = new Cache\MemcachedCacheDriver($memcached_host, $memcached_port);
self::$driver = new Cache\MemcachedCacheDriver($memcached_hosts);
break;
default:
self::$driver = new Cache\DatabaseCacheDriver();

View file

@ -17,7 +17,7 @@ class MemcachedCacheDriver extends BaseObject implements ICacheDriver
*/
private $memcached;
public function __construct($memcached_host, $memcached_port)
public function __construct(array $memcached_hosts)
{
if (!class_exists('Memcached', false)) {
throw new \Exception('Memcached class isn\'t available');
@ -25,8 +25,10 @@ class MemcachedCacheDriver extends BaseObject implements ICacheDriver
$this->memcached = new \Memcached();
if (!$this->memcached->addServer($memcached_host, $memcached_port)) {
throw new \Exception('Expected Memcached server at ' . $memcached_host . ':' . $memcached_port . ' isn\'t available');
$this->memcached->addServers($memcached_hosts);
if (count($this->memcached->getServerList()) == 0) {
throw new \Exception('Expected Memcached servers aren\'t available, config:' . var_export($memcached_hosts, true));
}
}