Skip to content

Commit

Permalink
Update memcached.php
Browse files Browse the repository at this point in the history
Same issue as with memcache.php
  • Loading branch information
itbra committed Feb 21, 2014
1 parent 095c74f commit 2210eeb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions libraries/joomla/session/storage/memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
*/
class JSessionStorageMemcached extends JSessionStorage
{
/**
* The registered servers stack.
*
* @var array
* @since 12.2
*/
private $_servers;

/**
* Constructor
*
Expand All @@ -33,18 +41,19 @@ public function __construct($options = array())
throw new RuntimeException('Memcached Extension is not available', 404);
}

parent::__construct($options);

$config = JFactory::getConfig();

// This will be an array of loveliness
// This might help: {@link http://www.php.net/manual/en/memcached.sessions.php#112439}
// @todo: multiple servers
$this->_servers = array(
array(
'host' => $config->get('memcache_server_host', 'localhost'),
'port' => $config->get('memcache_server_port', 11211)
)
);

parent::__construct($options);
}

/**
Expand All @@ -56,7 +65,11 @@ public function __construct($options = array())
*/
public function register()
{
ini_set('session.save_path', $this->_servers['host'] . ':' . $this->_servers['port']);
// This might help: {@link http://www.php.net/manual/en/memcached.sessions.php#112439}
// @todo: evaluate servers count first
$server = current($this->_servers);

ini_set('session.save_path', $server['host'] . ':' . $server['port']);
ini_set('session.save_handler', 'memcached');
}

Expand Down

0 comments on commit 2210eeb

Please sign in to comment.