Redis adapter.
Constructor.
| Type | Description |
|---|---|
| array | Configuration |
NULL
public function __construct(array $config)
{
parent::__construct();
$this->redis = new MRedis($config['configuration']);
}
Destructor.
NULL
public function __destruct()
{
session_write_close();
$this->redis = null;
}
Returns session data.
| Type | Description |
|---|---|
| string | Session id |
string
public function read($id)
{
return (string) $this->redis->get('sess_' . $id);
}
Writes data to the session.
| Type | Description |
|---|---|
| string | Session id |
| string | Session data |
NULL
public function write($id, $data)
{
$this->redis->set('sess_' . $id, $data);
$this->redis->expire('sess_' . $id, $this->maxLifetime);
return true;
}
Destroys the session.
| Type | Description |
|---|---|
| string | Session id |
boolean
public function destroy($id)
{
return (bool) $this->redis->del('sess_' . $id);
}
Session "constructor".
| Type | Description |
|---|---|
| string | Save path |
| string | Session name |
boolean
/** * Returns session data. * * @access public * @param string Session id
Session "destructor".
boolean
/** * Writes data to the session. * * @access public
Garbage collector.
| Type | Description |
|---|---|
| int | Lifetime in secods |
boolean
return true; }