X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FMemcachePlugin.php;h=8c8b8da6dc183cdd45dfef86598dee23fea58148;hb=58fde0dcb5342cb3d3ff44c2e54a077eea0e063e;hp=5f93e9a8367e53d1e4661a6029a748550f695559;hpb=a180658a3bfcf2b7b312058e3aa76e0e2467c2f8;p=quix0rs-gnu-social.git diff --git a/plugins/MemcachePlugin.php b/plugins/MemcachePlugin.php index 5f93e9a836..8c8b8da6dc 100644 --- a/plugins/MemcachePlugin.php +++ b/plugins/MemcachePlugin.php @@ -133,6 +133,23 @@ class MemcachePlugin extends Plugin return false; } + function onStartCacheReconnect(&$success) + { + if (empty($this->_conn)) { + // nothing to do + return true; + } + if ($this->persistent) { + common_log(LOG_ERR, "Cannot close persistent memcached connection"); + $success = false; + } else { + common_log(LOG_INFO, "Closing memcached connection"); + $success = $this->_conn->close(); + $this->_conn = null; + } + return false; + } + /** * Ensure that a connection exists * @@ -148,20 +165,18 @@ class MemcachePlugin extends Plugin $this->_conn = new Memcache(); if (is_array($this->servers)) { - foreach ($this->servers as $server) { - list($host, $port) = explode(';', $server); - if (empty($port)) { - $port = 11211; - } - - $this->_conn->addServer($host, $port, $this->persistent); - } + $servers = $this->servers; } else { - $this->_conn->addServer($this->servers, $this->persistent); - list($host, $port) = explode(';', $this->servers); - if (empty($port)) { + $servers = array($this->servers); + } + foreach ($servers as $server) { + if (strpos($server, ';') !== false) { + list($host, $port) = explode(';', $server); + } else { + $host = $server; $port = 11211; } + $this->_conn->addServer($host, $port, $this->persistent); }