构造方法需要增加最后三行内容
public function __construct($options=array()) {
if ( !extension_loaded('redis') ) {
e(l('_not_support_').':redis');
}
$data_redis_db = c('redis_db');
$options = array_merge(array (
'host' => c('redis_host') ? : '127.0.0.1',
'port' => c('redis_port') ? : 6379,
'timeout' => c('data_cache_timeout') ? : false,
'persistent' => false,
'auth' => c('redis_auth') ? c('redis_auth') : false,
'db' => empty($data_redis_db) ? 0 : $data_redis_db,
),$options);
$this->options = $options;
$this->options['expire'] = isset($options['expire'])? $options['expire'] : c('data_cache_time');
$this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : c('data_cache_prefix');
$this->options['length'] = isset($options['length'])? $options['length'] : 0;
$func = $options['persistent'] ? 'pconnect' : 'connect';
$this->handler = new \redis;
$options['timeout'] === false ?
$this->handler->$func($options['host'], $options['port']) :
$this->handler->$func($options['host'], $options['port'], $options['timeout']);
//增加代码,设置redis安全性,增加认证密码
if(isset($options['auth']) && $options['auth']){
$this->handler->auth($options['auth']);
}
}
ad:真正免费,域名+虚机+企业邮箱=0元