From f5df02a75de6e8cd2d81fe72d5f296617bdb6b25 Mon Sep 17 00:00:00 2001 From: Tomasz Narloch Date: Sat, 13 Aug 2016 23:31:56 +0200 Subject: [PATCH] No static var --- libraries/joomla/cache/storage/memcache.php | 22 +++++++-------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/libraries/joomla/cache/storage/memcache.php b/libraries/joomla/cache/storage/memcache.php index b045b16ee431c..e9bf2f027cba3 100644 --- a/libraries/joomla/cache/storage/memcache.php +++ b/libraries/joomla/cache/storage/memcache.php @@ -25,21 +25,13 @@ class JCacheStorageMemcache extends JCacheStorage */ protected static $_db = null; - /** - * Persistent session flag - * - * @var boolean - * @since 11.1 - */ - protected static $_persistent = false; - /** * Payload compression level * * @var integer * @since 11.1 */ - protected static $_compress = 0; + protected $_compress = 0; /** * Constructor @@ -52,6 +44,8 @@ public function __construct($options = array()) { parent::__construct($options); + $this->_compress = JFactory::getConfig()->get('memcache_compress', false) ? MEMCACHE_COMPRESSED : 0; + if (static::$_db === null) { $this->getConnection(); @@ -81,11 +75,7 @@ protected function getConnection() // Create the memcache connection static::$_db = new Memcache; - // If memcache object is static then $_persistent and $_compress too - static::$_persistent = $config->get('memcache_persist', true); - static::$_compress = $config->get('memcache_compress', false) ? MEMCACHE_COMPRESSED : 0; - - if (static::$_persistent) + if ($config->get('memcache_persist', true)) { $result = @static::$_db->pconnect($host, $port); } @@ -96,6 +86,8 @@ protected function getConnection() if (!$result) { + static::$_db = null; + throw new RuntimeException('Could not connect to memcache server'); } } @@ -195,7 +187,7 @@ public function store($id, $group, $data) static::$_db->set($this->_hash . '-index', $index, 0, 0); $this->unlockindex(); - static::$_db->set($cache_id, $data, static::$_compress, $this->_lifetime); + static::$_db->set($cache_id, $data, $this->_compress, $this->_lifetime); return true; }