From 07a30734a35cf542bfb93d6127e0e72fbbcfef98 Mon Sep 17 00:00:00 2001 From: dingdayu <614422099@qq.com> Date: Thu, 1 Sep 2016 17:43:53 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20#253=20*=20=E5=A2=9E=E5=8A=A0cache/sess?= =?UTF-8?q?ion=20redis=E9=A9=B1=E5=8A=A8=E7=9A=84=E5=BA=93=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=80=BB=E8=BE=91;=20*=20hint:=20=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=9C=A8=E7=BC=93=E5=AD=98=E9=85=8D=E7=BD=AE(cache=E8=8A=82?= =?UTF-8?q?=E7=82=B9)=E4=B8=AD=E5=A2=9E=E5=8A=A0'select';=20*=20eg:=20['ca?= =?UTF-8?q?che'=20=3D>=20['select'=3D>0,=20...]];?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/driver/Redis.php | 5 +++++ library/think/session/driver/Redis.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/library/think/cache/driver/Redis.php b/library/think/cache/driver/Redis.php index cd33523f..1f8686af 100644 --- a/library/think/cache/driver/Redis.php +++ b/library/think/cache/driver/Redis.php @@ -27,6 +27,7 @@ class Redis extends Driver 'host' => '127.0.0.1', 'port' => 6379, 'password' => '', + 'select' => 0, 'timeout' => 0, 'expire' => 0, 'persistent' => false, @@ -53,6 +54,10 @@ class Redis extends Driver if ('' != $this->options['password']) { $this->handler->auth($this->options['password']); } + + if (0 != $this->options['select']) { + $this->handler->select($this->options['select']); + } } /** diff --git a/library/think/session/driver/Redis.php b/library/think/session/driver/Redis.php index 367df10c..e3dc9983 100644 --- a/library/think/session/driver/Redis.php +++ b/library/think/session/driver/Redis.php @@ -22,6 +22,7 @@ class Redis extends SessionHandler 'host' => '127.0.0.1', // redis主机 'port' => 6379, // redis端口 'password' => '', // 密码 + 'select' => 0, // 操作库 'expire' => 3600, // 有效期(秒) 'timeout' => 0, // 超时时间(秒) 'persistent' => true, // 是否长连接 @@ -56,6 +57,11 @@ class Redis extends SessionHandler if ('' != $this->config['password']) { $this->handler->auth($this->config['password']); } + + if (0 != $this->config['select']) { + $this->handler->select($this->config['select']); + } + return true; }