public function __construct($settings = [])
{
// check Redis extension
if (!extension_loaded('redis')) {
throw new ComponentException("Redis extension not installed/enabled.\n Install and/or enable Redis extension [http://pecl.php.net/package/redis].\n See phpinfo() for more information");
}
// check Redis settings
if (!is_array($settings) || empty($settings)) {
throw new ConfigurationException("Redis configuration is missed. Please check 'session' configuration section");
}
$this->settings = array_replace_recursive($this->settings, $settings);
$this->handler = new \Redis();
if ($this->settings['persistence']) {
$this->handler->pconnect($this->settings['host'], $this->settings['port'], $this->settings['timeout']);
} else {
$this->handler->connect($this->settings['host'], $this->settings['port'], $this->settings['timeout']);
}
if (isset($this->settings['options'])) {
foreach ($this->settings['options'] as $key => $value) {
$this->handler->setOption($key, $value);
}
}
}