コード例 #1
0
 /**
  * Constructor.
  *
  * @param string                $dbPath     Path to SQLite database file.
  * @param array                 $options    Session configuration options.
  *
  * @see AbstractSessionStorage::__construct()
  */
 public function __construct($dbPath, array $options = array())
 {
     if (!extension_loaded('sqlite')) {
         throw new \RuntimeException('PHP does not have "sqlite" session module registered');
     }
     $this->dbPath = $dbPath;
     parent::__construct($options);
 }
コード例 #2
0
 /**
  * Constructor.
  *
  *
  * @param \PDO                  $pdo        A \PDO instance
  * @param array                 $dbOptions  An associative array of DB options
  * @param array                 $options    Session configuration options
  *
  * @throws \InvalidArgumentException When "db_table" option is not provided
  *
  * @see AbstractSessionStorage::__construct()
  */
 public function __construct(\PDO $pdo, array $dbOptions = array(), array $options = array())
 {
     if (!array_key_exists('db_table', $dbOptions)) {
         throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.');
     }
     $this->pdo = $pdo;
     $this->dbOptions = array_merge(array('db_id_col' => 'sess_id', 'db_data_col' => 'sess_data', 'db_time_col' => 'sess_time'), $dbOptions);
     parent::__construct($options);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  *
  * Sets any values memcached ini values.
  *
  * @see http://www.php.net/manual/en/memcache.ini.php
  */
 protected function setOptions(array $options)
 {
     foreach ($options as $key => $value) {
         if (in_array($key, array('memcache.allow_failover', 'memcache.max_failover_attempts', 'memcache.chunk_size', 'memcache.default_port', 'memcache.hash_strategy', 'memcache.hash_function', 'memcache.protocol', 'memcache.redundancy', 'memcache.session_redundancy', 'memcache.compress_threshold', 'memcache.lock_timeout'))) {
             ini_set($key, $value);
         }
     }
     parent::setOptions($options);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  *
  * Sets any values memcached ini values.
  *
  * @see https://github.com/php-memcached-dev/php-memcached/blob/master/memcached.ini
  */
 protected function setOptions(array $options)
 {
     foreach ($options as $key => $value) {
         if (in_array($key, array('memcached.sess_locking', 'memcached.sess_lock_wait', 'memcached.sess_prefix', 'memcached.compression_type', 'memcached.compression_factor', 'memcached.compression_threshold', 'memcached.serializer'))) {
             ini_set($key, $value);
         }
     }
     parent::setOptions($options);
 }
コード例 #5
0
 /**
  * Constructor.
  *
  * @param string                $savePath   Path of directory to save session files.
  * @param array                 $options    Session configuration options.
  *
  * @see AbstractSessionStorage::__construct()
  */
 public function __construct($savePath = null, array $options = array())
 {
     if (null === $savePath) {
         $savePath = sys_get_temp_dir();
     }
     if (!is_dir($savePath)) {
         mkdir($savePath, 0777, true);
     }
     $this->savePath = $savePath;
     parent::__construct($options);
 }
コード例 #6
0
 /**
  * Constructor.
  *
  * @param \Memcached            $memcached        A \Memcached instance
  * @param array                 $memcachedOptions An associative array of Memcached options
  * @param array                 $options          Session configuration options.
  *
  * @see AbstractSessionStorage::__construct()
  */
 public function __construct(\Memcached $memcached, array $memcachedOptions = array(), array $options = array())
 {
     $this->memcached = $memcached;
     // defaults
     if (!isset($memcachedOptions['serverpool'])) {
         $memcachedOptions['serverpool'][] = array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 1);
     }
     $memcachedOptions['expiretime'] = isset($memcachedOptions['expiretime']) ? (int) $memcachedOptions['expiretime'] : 86400;
     $this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, isset($memcachedOptions['prefix']) ? $memcachedOptions['prefix'] : 'sf2s');
     $this->memcachedOptions = $memcachedOptions;
     parent::__construct($options);
 }
コード例 #7
0
 /**
  * Constructor.
  *
  * @param \Memcache             $memcache        A \Memcache instance
  * @param array                 $memcacheOptions An associative array of Memcachge options
  * @param array                 $options         Session configuration options.
  *
  * @see AbstractSessionStorage::__construct()
  */
 public function __construct(\Memcache $memcache, array $memcacheOptions = array(), array $options = array())
 {
     $this->memcache = $memcache;
     // defaults
     if (!isset($memcacheOptions['serverpool'])) {
         $memcacheOptions['serverpool'] = array(array('host' => '127.0.0.1', 'port' => 11211, 'timeout' => 1, 'persistent' => false, 'weight' => 1, 'retry_interval' => 15));
     }
     $memcacheOptions['expiretime'] = isset($memcacheOptions['expiretime']) ? (int) $memcacheOptions['expiretime'] : 86400;
     $this->prefix = isset($memcacheOptions['prefix']) ? $memcacheOptions['prefix'] : 'sf2s';
     $this->memcacheOptions = $memcacheOptions;
     parent::__construct($options);
 }