取消 url_module_map 配置参数 改进Redis session驱动

This commit is contained in:
thinkphp
2016-05-21 15:21:12 +08:00
parent 3bcb764973
commit 744cdaebff
2 changed files with 10 additions and 12 deletions

View File

@@ -18,13 +18,13 @@ class Redis extends SessionHandler
{
protected $handler = null;
protected $config = [
'host' => '127.0.0.1', // redis主机
'port' => 6379, // redis端口
'password' => '', // 密码
'expire' => 3600, // 有效期(秒)
'timeout' => 0, // 超时时间(秒)
'persistent' => true, // 是否长连接
'session_name' => '', // sessionkey前缀
'host' => '127.0.0.1', // redis主机
'port' => 6379, // redis端口
'password' => '', // 密码
'expire' => 3600, // 有效期(秒)
'timeout' => 0, // 超时时间(秒)
'persistent' => true, // 是否长连接
'session_name' => '', // sessionkey前缀
];
public function __construct($config = [])
@@ -45,11 +45,11 @@ class Redis extends SessionHandler
throw new Exception('_NOT_SUPPERT_:redis');
}
$this->handler = new \Redis;
// 建立连接
$func = $this->config['persistent'] ? 'pconnect' : 'connect';
$this->handler->$func($this->config['host'], $this->config['port'], $this->config['timeout']);
if ('' != $this->config['password']) {
$this->handler->auth($this->config['password']);
}
@@ -100,7 +100,7 @@ class Redis extends SessionHandler
*/
public function destroy($sessID)
{
return $this->handler->delete($this->config['session_name'] . $sessID);
return $this->handler->delete($this->config['session_name'] . $sessID) ? true : false;
}
/**