for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* sessionware (https://github.com/juliangut/sessionware).
* PSR7 session management middleware.
*
* @license BSD-3-Clause
* @link https://github.com/juliangut/sessionware
* @author Julián Gutiérrez <[email protected]>
*/
declare(strict_types=1);
namespace Jgut\Sessionware\Handler;
/**
* Redis session handler.
class Redis implements Handler
{
use HandlerTrait;
* @var \Redis
protected $driver;
* Redis session handler constructor.
* @param \Redis $driver
public function __construct(\Redis $driver)
$this->driver = $driver;
}
* {@inheritdoc}
* @throws \RuntimeException
* @SuppressWarnings(PMD.UnusedFormalParameter)
public function open($savePath, $sessionName)
$this->testConfiguration();
return true;
public function close()
public function read($sessionId)
$sessionData = $this->driver->get($sessionId);
$this->driver->expire($sessionId, $this->configuration->getLifetime());
return $sessionData;
public function write($sessionId, $sessionData)
$this->driver->set($sessionId, $sessionData);
public function destroy($sessionId)
$this->driver->del($sessionId);
* @SuppressWarnings(PMD.ShortMethodName)
public function gc($maxLifetime)