Skip to content

RedisSessionFactory

session slot factory for RedisSessionPersistence.

yaml session: class: Quiote\Session\Redis\RedisSessionFactory params: dsn: 'redis://127.0.0.1:6379' prefix: 'session:' ttl: 1440

Redis expires the key itself, so ttl doubles as the session lifetime and there is no garbage-collection pass to schedule.

final class RedisSessionFactory implements SessionFactoryInterface

ImplementsSessionFactoryInterface
Since3.0.0
SourceRedisSessionFactory.php
MethodDescription
createPersistence(Context $context, array $parameters): SessionPersistenceInterfaceBuilds a RedisSessionPersistence over a Predis client.

public function createPersistence(Context $context, array $parameters): SessionPersistenceInterface

Builds a RedisSessionPersistence over a Predis client.

Parameters, all optional: dsn (default redis://127.0.0.1:6379), prefix (default session:) and ttl in seconds (default 1440), which Redis enforces as the session lifetime.

ParameterTypeDescription
$contextContext
$parametersarray

Returns SessionPersistenceInterface

ThrowsWhen
RuntimeExceptionif predis/predis is not installed.