public function __construct() { $config = Config::get('redis'); if (!$config) { throw new ServiceUnavailableException("'redis' config key missing."); } $client = new Predis\Client($config, array('prefix' => 'sessions:')); // Set `gc_maxlifetime` to specify a time-to-live of 5 seconds for session keys. parent::__construct($client); // , array('gc_maxlifetime' => 5) }
/** * @Inject({ * "@redis", * "%session.lifetime%" * }) * @param ClientInterface $client * @param int $lifetime */ public function __construct(ClientInterface $client, $lifetime) { parent::__construct($client, ['gc_maxlifetime' => $lifetime]); }