Skip to content

Commit

Permalink
Redis 主从复制Master和Slave
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinywan committed Nov 1, 2016
1 parent 4e7ee7e commit 1a63fd7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 142 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Backend/Home/Controller/DataBaseController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,14 @@ public function addAll($dataList, $options = array(), $replace = false)
return $result;
}

public function test(){
$aa = '4001:user_id';
$messageId = explode(':',$aa);
switch($messageId[0]){
case 4001:

}
echo $messageId[1];
}

}
35 changes: 35 additions & 0 deletions Backend/Home/Controller/IndexController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Home\Controller;

use Home\Controller\BaseController;
use Org\Util\RedisInstance;
use Org\Util\Tree;
use Org\Util\UserAgent;
use Org\Util\Rbac;
Expand All @@ -14,6 +15,7 @@ public function index()

$user = M('AdminUser')->select();
$where['username'] = session('username');

$user = M('AdminUser')->where($where)->field(['username', 'logintime', 'loginip', 'expire'])->find();
$this->user = $user;
$this->display();
Expand Down Expand Up @@ -124,4 +126,37 @@ public function curltest()
preg_match("/[0-9]+[^\s]*[0-9]/",$str,$matches);
var_dump($matches[0]);
}

public function testRedis(){
$session_name = 'tinywan';
$save_path = 'F:/wamp/sessionredis';
$session_expire = 60;
echo session_id();
$redis = RedisInstance::MasterInstance();
$str = 'PHPREDIS_SESSION:1a2t9ln6so69j38frhivm79ak0';
homePrint($redis->get($str));
var_dump(session('_ACCESS_LIST'));
die;

session_save_path($save_path);
session_name($session_name);
session_cache_expire($session_expire);

echo 'session_name:'.session_name().'session_id:'.session_id().'session_expire:'.session_cache_expire();

$redis = RedisInstance::MasterInstance();
$redis->select(3);
echo session_name().'='.session_id();
die;
}

public function getSessionRedis(){
// echo 'session_name:'.session_name().'session_id:'.session_id().'session_expire:'.session_cache_expire();
echo '========'.session_save_path();
$redis = RedisInstance::MasterInstance();
$redis->hSet();
$redis->select(3);
echo session_name().'='.session_id();
die;
}
}
141 changes: 0 additions & 141 deletions ThinkPHP/Library/Org/Util/RedisInstance.class.php

This file was deleted.

0 comments on commit 1a63fd7

Please sign in to comment.