summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-03-12 11:13:43 +0100
committerAndrey Andreev <narf@devilix.net>2016-03-12 11:13:43 +0100
commit24027c1b85f9d2e08b95fd49d6bba65468fea07c (patch)
treecd258a21b6cbef51590ba6fb835db57522c7b993
parenta190d78a0238a0a6abd463823321bef15713e312 (diff)
parentbbfa3ffdb8096e9d20b800ebbc8de672caf98d9e (diff)
Merge pull request #4522 from masterklavi/memcached_destruct
Added destructor to Cache_memcached
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 7e67fc40f..8bb4a5696 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -287,4 +287,25 @@ class CI_Cache_memcached extends CI_Driver {
{
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();
+ }
+ }
}