This class is mostly intended for PHP 5.4 but it can be used under PHP 5.3 provided that a polyfill for SessionHandlerInterface is defined by either you or an external package such as symfony/http-foundation.
Author: Daniele Alessandri (suppakilla@gmail.com)
Inheritance: implements SessionHandlerInterface
Beispiel #1
0
 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)
 }
Beispiel #2
0
 /**
  * @Inject({
  *     "@redis",
  *     "%session.lifetime%"
  * })
  * @param ClientInterface $client
  * @param int $lifetime
  */
 public function __construct(ClientInterface $client, $lifetime)
 {
     parent::__construct($client, ['gc_maxlifetime' => $lifetime]);
 }