Skip to content

Commit

Permalink
No static var
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Narloch committed Aug 18, 2016
1 parent b89158d commit f5df02a
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions libraries/joomla/cache/storage/memcache.php
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand All @@ -96,6 +86,8 @@ protected function getConnection()

if (!$result)
{
static::$_db = null;

throw new RuntimeException('Could not connect to memcache server');
}
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f5df02a

Please sign in to comment.