From bbfa3ffdb8096e9d20b800ebbc8de672caf98d9e Mon Sep 17 00:00:00 2001 From: Masterklavi Date: Sat, 12 Mar 2016 11:12:58 +0500 Subject: Added the destructor (disconnect from memcache(d)) --- system/libraries/Cache/drivers/Cache_memcached.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'system/libraries/Cache/drivers/Cache_memcached.php') diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index c44958b97..91ad4d243 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -286,4 +286,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(); + } + } } -- cgit v1.2.3-24-g4f1b