Skip to content

Commit 1a63fd7

Browse files
committed
Redis 主从复制Master和Slave
1 parent 4e7ee7e commit 1a63fd7

File tree

4 files changed

+45
-142
lines changed

4 files changed

+45
-142
lines changed

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Backend/Home/Controller/DataBaseController.class.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,4 +355,14 @@ public function addAll($dataList, $options = array(), $replace = false)
355355
return $result;
356356
}
357357

358+
public function test(){
359+
$aa = '4001:user_id';
360+
$messageId = explode(':',$aa);
361+
switch($messageId[0]){
362+
case 4001:
363+
364+
}
365+
echo $messageId[1];
366+
}
367+
358368
}

Backend/Home/Controller/IndexController.class.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Home\Controller;
33

44
use Home\Controller\BaseController;
5+
use Org\Util\RedisInstance;
56
use Org\Util\Tree;
67
use Org\Util\UserAgent;
78
use Org\Util\Rbac;
@@ -14,6 +15,7 @@ public function index()
1415

1516
$user = M('AdminUser')->select();
1617
$where['username'] = session('username');
18+
1719
$user = M('AdminUser')->where($where)->field(['username', 'logintime', 'loginip', 'expire'])->find();
1820
$this->user = $user;
1921
$this->display();
@@ -124,4 +126,37 @@ public function curltest()
124126
preg_match("/[0-9]+[^\s]*[0-9]/",$str,$matches);
125127
var_dump($matches[0]);
126128
}
129+
130+
public function testRedis(){
131+
$session_name = 'tinywan';
132+
$save_path = 'F:/wamp/sessionredis';
133+
$session_expire = 60;
134+
echo session_id();
135+
$redis = RedisInstance::MasterInstance();
136+
$str = 'PHPREDIS_SESSION:1a2t9ln6so69j38frhivm79ak0';
137+
homePrint($redis->get($str));
138+
var_dump(session('_ACCESS_LIST'));
139+
die;
140+
141+
session_save_path($save_path);
142+
session_name($session_name);
143+
session_cache_expire($session_expire);
144+
145+
echo 'session_name:'.session_name().'session_id:'.session_id().'session_expire:'.session_cache_expire();
146+
147+
$redis = RedisInstance::MasterInstance();
148+
$redis->select(3);
149+
echo session_name().'='.session_id();
150+
die;
151+
}
152+
153+
public function getSessionRedis(){
154+
// echo 'session_name:'.session_name().'session_id:'.session_id().'session_expire:'.session_cache_expire();
155+
echo '========'.session_save_path();
156+
$redis = RedisInstance::MasterInstance();
157+
$redis->hSet();
158+
$redis->select(3);
159+
echo session_name().'='.session_id();
160+
die;
161+
}
127162
}

ThinkPHP/Library/Org/Util/RedisInstance.class.php

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)