Merge pull request #4522 from masterklavi/memcached_destruct
Added destructor to Cache_memcached
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 7e67fc4..8bb4a56 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -287,4 +287,25 @@
{
return (extension_loaded('memcached') OR extension_loaded('memcache'));
}
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Class destructor
+ *
+ * Closes the connection to Memcache(d) if present.
+ *
+ * @return void
+ */
+ public function __destruct()
+ {
+ if ($this->_memcached instanceof Memcache)
+ {
+ $this->_memcached->close();
+ }
+ elseif ($this->_memcached instanceof Memcached)
+ {
+ $this->_memcached->quit();
+ }
+ }
}