From 7e90b1191af892249e0ffd92f0452fa92446b03c Mon Sep 17 00:00:00 2001 From: Tinywan <756684177@qq.com> Date: Sat, 29 Oct 2016 17:15:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BE=8B=E6=A8=A1=E5=BC=8F,=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E5=AF=B9=E8=B1=A1=E5=85=B1=E4=BA=AB=E4=B8=80=E5=9D=97?= =?UTF-8?q?=E5=86=85=E5=AD=98=E5=8C=BA=E5=9F=9F(=E5=AE=9E=E4=BE=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Home/Controller/DataBaseController.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Backend/Home/Controller/DataBaseController.class.php b/Backend/Home/Controller/DataBaseController.class.php index 84ebbc3..1cdd1fb 100644 --- a/Backend/Home/Controller/DataBaseController.class.php +++ b/Backend/Home/Controller/DataBaseController.class.php @@ -61,10 +61,15 @@ public function localhostRedis(){ } /** + * 单列模式参考连接:http://www.cnblogs.com/hongfei/archive/2012/07/07/2580994.html + * 【官方解释】: + * 如果两个对象是同一个类的实例,且它们有相同的属性和值,则这两个对象相等。类似的规则还适用与用全等符(===)对两个对象的比较。 + * http://php.net/manual/zh/oop4.object-comparison.php * 是否是同一个对象的比较 * 比较结果: * 【redis1和redis2:是同一个实例--redis1和redis3:是同一个实例--redis2和redis3:是同一个实例--】 * 对象$redis1,$redis2,$redis3实际上都是使用同一个对象实例,访问的都是同一块内存区域 + * */ public function ObjectCompare() { @@ -98,7 +103,7 @@ public function ObjectCompare() */ public function createRedis() { - $redis = RedisInstance::getInstance(); + $redis = RedisInstance::MasterInstance(); $redis->select(1); $message = [ 'type' => 'say', @@ -130,7 +135,7 @@ public function executeFunction() */ public function getRedisData() { - $redis = RedisInstance::getInstance(); + $redis = RedisInstance::MasterInstance(); $redis->select(1); $redisInfo = $redis->lRange('message01',0,-1); var_dump($redisInfo);