8 use Cm\RedisSession\Handler\ConfigInterface;
9 use Cm\RedisSession\Handler\LoggerInterface;
10 use Cm\RedisSession\ConnectionFailedException;
11 use Cm\RedisSession\ConcurrentConnectionsExceededException;
17 class Redis implements \SessionHandlerInterface
58 private function getConnection()
61 if (!isset($this->connection[$pid])) {
63 $this->connection[$pid] = new \Cm\RedisSession\Handler($this->config, $this->logger);
64 }
catch (ConnectionFailedException $e) {
68 return $this->connection[$pid];
79 public function open($savePath, $sessionName)
81 return $this->getConnection()->open($savePath, $sessionName);
92 public function read($sessionId)
95 return $this->getConnection()->read($sessionId);
96 }
catch (ConcurrentConnectionsExceededException $e) {
97 require $this->filesystem->getDirectoryRead(
DirectoryList::PUB)->getAbsolutePath(
'errors/503.php');
109 public function write($sessionId, $sessionData)
111 return $this->getConnection()->write($sessionId, $sessionData);
123 return $this->getConnection()->destroy($sessionId);
134 return $this->getConnection()->close();
145 public function gc($maxLifeTime)
147 return $this->getConnection()->gc($maxLifeTime);
158 return $this->getConnection()->getFailedLockAttempts();
__construct(ConfigInterface $config, LoggerInterface $logger, Filesystem $filesystem)
write($sessionId, $sessionData)
open($savePath, $sessionName)