Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/EpiCache_Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class EpiCache_Memcached extends EpiCache
public function __construct($params = array())
{
$this->host = !empty($params[0]) ? $params[0] : 'localhost';
$this->port = !empty($params[1]) ? $params[1] : 11211;;
$this->compress = !empty($params[2]) ? $params[2] : 0;;
$this->expiry = !empty($params[3]) ? $params[3] : 3600;
$this->port = !empty($params[1]) ? $params[1] : 11211;
$this->compress = isset($params[2]) ? $params[2] : 0;
$this->expiry = isset($params[3]) ? $params[3] : 3600;
}

public function delete($key, $timeout = 0)
Expand Down
25 changes: 15 additions & 10 deletions src/EpiSession_Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@
class EpiSession_Memcached implements EpiSessionInterface
{
private static $connected = false;
private $key = null;
private $store= null;
private $memcached = false;
private $key = null;
private $store = null;
private $host = null;
private $port = null;
private $compress = null;
private $expiry = null;

public function __construct($params = array())
{
if(empty($_COOKIE[EpiSession::COOKIE]))
{
$cookieVal = md5(uniqid(rand(), true));
setcookie(EpiSession::COOKIE, $cookieVal, time()+1209600, '/');
$_COOKIE[EpiSession::COOKIE] = $cookieVal;
$key = md5(uniqid(rand(), true));
setcookie(EpiSession::COOKIE, $key, time() + 1209600, '/');
$_COOKIE[EpiSession::COOKIE] = $key;
}
$this->host = !empty($params[0]) ? $params[0] : 'localhost';
$this->port = !empty($params[1]) ? $params[1] : 11211;;
$this->compress = !empty($params[2]) ? $params[2] : 0;;
$this->expiry = !empty($params[3]) ? $params[3] : 3600;
$this->port = !empty($params[1]) ? $params[1] : 11211;
$this->compress = isset($params[2]) ? $params[2] : 0;
$this->expiry = isset($params[3]) ? $params[3] : 3600;
}

public function end()
Expand Down Expand Up @@ -51,7 +56,7 @@ public function set($key = null, $value = null)
return false;

$this->store[$key] = $value;
$this->memcached->set($this->key, $this->store);
$this->memcached->set($this->key, $this->store, $this->expiry);
return $value;
}

Expand All @@ -66,7 +71,7 @@ private function connect($params = null)
if($this->memcached->addServer($this->host, $this->port))
{
self::$connected = true;
$this->key = empty($key) ? $_COOKIE[EpiSession::COOKIE] : $key;
$this->key = $_COOKIE[EpiSession::COOKIE];
$this->store = $this->getAll();
return true;
}
Expand Down