diff --git a/.idea/misc.xml b/.idea/misc.xml index b0f8c53..c9a8380 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -16,5 +16,4 @@ - \ No newline at end of file diff --git a/Backend/Home/Controller/DataBaseController.class.php b/Backend/Home/Controller/DataBaseController.class.php index 5b4ea3e..1aee8ac 100644 --- a/Backend/Home/Controller/DataBaseController.class.php +++ b/Backend/Home/Controller/DataBaseController.class.php @@ -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]; + } + } diff --git a/Backend/Home/Controller/IndexController.class.php b/Backend/Home/Controller/IndexController.class.php index 4658ab1..459f7ad 100644 --- a/Backend/Home/Controller/IndexController.class.php +++ b/Backend/Home/Controller/IndexController.class.php @@ -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; @@ -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(); @@ -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; + } } \ No newline at end of file diff --git a/ThinkPHP/Library/Org/Util/RedisInstance.class.php b/ThinkPHP/Library/Org/Util/RedisInstance.class.php deleted file mode 100644 index d04815b..0000000 --- a/ThinkPHP/Library/Org/Util/RedisInstance.class.php +++ /dev/null @@ -1,141 +0,0 @@ -connect('121.41.88.209', '63789'); - self::Instance()->auth('tinywanredis'); - return static::$_instance; - }catch (\Exception $e){ - return false; - } - } - - - /** - * Slave1 实例 - * @return null - * @static - */ - public static function SlaveOneInstance() - { - try{ - self::Instance()->connect('121.41.88.209', '63788'); - return static::$_instance; - }catch (\Exception $e){ - return false; - } - } - - /** - * Slave2 实例 - * @return null - * @static - */ - public static function SlaveTwoInstance() - { - try{ - self::Instance()->connect('121.41.88.209', '63700'); - return static::$_instance; - }catch (\Exception $e){ - return false; - } - } - - /** - * Redis数据库是否连接成功 - * @return bool|string - */ - public static function connect() - { - // 如果连接资源不存在,则进行资源连接 - if (!self::$_connectSource) - { - //@return bool TRUE on success, FALSE on error. - self::$_connectSource = self::Instance()->connect('121.41.88.209', '63789'); - // 没有资源返回 - if (!self::$_connectSource) - { - return 'Redis Server Connection Fail'; - } - } - return self::$_connectSource; - } - - /** - * 私有化克隆函数,防止类外克隆对象 - */ - private function __clone() - { - // TODO: Implement __clone() method. - } - - - /** - * @return \Redis - * @static - */ - public static function test() - { - return 'test'; - } -} \ No newline at end of file