Add support for multiple Memcached servers
- Updated htconfig documentation
This commit is contained in:
parent
95752b79e8
commit
059b1f63f8
3 changed files with 8 additions and 8 deletions
|
@ -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
|
* **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_host** - Host name of the memcache daemon. Default is '127.0.0.1'.
|
||||||
* **memcache_port** - Port number of the memcache daemon. Default is 11211.
|
* **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_hosts** - Array of Memcached servers info [host, port(, weight)]. Default is [['127.0.0.1', 11211]]
|
||||||
* **memcached_port** - Port number of the memcached daemon. Default is 11211.
|
|
||||||
* **no_count** (Boolean) - Don't do count calculations (currently only when showing albums)
|
* **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_oembed** (Boolean) - Don't use OEmbed to fetch more information about a link.
|
||||||
* **no_smilies** (Boolean) - Don't show smilies.
|
* **no_smilies** (Boolean) - Don't show smilies.
|
||||||
|
|
|
@ -36,10 +36,9 @@ class Cache extends \Friendica\BaseObject
|
||||||
self::$driver = new Cache\MemcacheCacheDriver($memcache_host, $memcache_port);
|
self::$driver = new Cache\MemcacheCacheDriver($memcache_host, $memcache_port);
|
||||||
break;
|
break;
|
||||||
case 'memcached':
|
case 'memcached':
|
||||||
$memcached_host = Config::get('system', 'memcached_host', '127.0.0.1');
|
$memcached_hosts = Config::get('system', 'memcached_hosts', [['127.0.0.1', 11211]]);
|
||||||
$memcached_port = Config::get('system', 'memcached_port', 11211);
|
|
||||||
|
|
||||||
self::$driver = new Cache\MemcachedCacheDriver($memcached_host, $memcached_port);
|
self::$driver = new Cache\MemcachedCacheDriver($memcached_hosts);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
self::$driver = new Cache\DatabaseCacheDriver();
|
self::$driver = new Cache\DatabaseCacheDriver();
|
||||||
|
|
|
@ -17,7 +17,7 @@ class MemcachedCacheDriver extends BaseObject implements ICacheDriver
|
||||||
*/
|
*/
|
||||||
private $memcached;
|
private $memcached;
|
||||||
|
|
||||||
public function __construct($memcached_host, $memcached_port)
|
public function __construct(array $memcached_hosts)
|
||||||
{
|
{
|
||||||
if (!class_exists('Memcached', false)) {
|
if (!class_exists('Memcached', false)) {
|
||||||
throw new \Exception('Memcached class isn\'t available');
|
throw new \Exception('Memcached class isn\'t available');
|
||||||
|
@ -25,8 +25,10 @@ class MemcachedCacheDriver extends BaseObject implements ICacheDriver
|
||||||
|
|
||||||
$this->memcached = new \Memcached();
|
$this->memcached = new \Memcached();
|
||||||
|
|
||||||
if (!$this->memcached->addServer($memcached_host, $memcached_port)) {
|
$this->memcached->addServers($memcached_hosts);
|
||||||
throw new \Exception('Expected Memcached server at ' . $memcached_host . ':' . $memcached_port . ' isn\'t available');
|
|
||||||
|
if (count($this->memcached->getServerList()) == 0) {
|
||||||
|
throw new \Exception('Expected Memcached servers aren\'t available, config:' . var_export($memcached_hosts, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue