diff --git a/classes/Cache.php b/classes/Cache.php index 98c6c95..fc2ee02 100644 --- a/classes/Cache.php +++ b/classes/Cache.php @@ -44,6 +44,14 @@ class Cache extends Object */ private $namespace = ''; + /** + * Servers + * + * @access private + * @var integer + */ + private $servers = 0; + /** * Connection resource to Memcached * @@ -84,6 +92,7 @@ class Cache extends Object $datasource = $this->config->datasources[$name]; $this->connection->addServer($datasource['hostname'], $datasource['port']); + $this->servers++; if (isset($datasource['namespace'])) { @@ -106,7 +115,7 @@ class Cache extends Object */ public function __destruct() { - if ($this->connection) + if ($this->servers) { $this->connection->close(); } diff --git a/jar.php b/jar.php index 7da0b15..f94d1c3 100755 --- a/jar.php +++ b/jar.php @@ -623,6 +623,14 @@ class Cache extends Object */ private $namespace = ''; + /** + * Servers + * + * @access private + * @var integer + */ + private $servers = 0; + /** * Connection resource to Memcached * @@ -663,6 +671,7 @@ class Cache extends Object $datasource = $this->config->datasources[$name]; $this->connection->addServer($datasource['hostname'], $datasource['port']); + $this->servers++; if (isset($datasource['namespace'])) { @@ -685,7 +694,7 @@ class Cache extends Object */ public function __destruct() { - if ($this->connection) + if ($this->servers) { $this->connection->close(); }