1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace Common\Cache;
- use Think\Cache\Driver\Redis;
- /**
- * redis
- */
- class RedisCache extends Redis {
- public static $_Redis = array();
- public function __construct($options = array('host' => REDIS_HOST, 'port' => REDIS_PORT, 'auth' => REDIS_AUTH)) {
- parent::__construct($options);
- }
- public function getkey() {
- $res = $this->keys('*');
- return $res;
- }
- /**
- * 获取app用户的token
- * @author: huangch
- * @return mixed
- */
- public function get_user_token($uid) {
- return $this->get('x_user_token:'.$uid);
- }
- /**
- * 获取app用户的refresh_token
- * @author: huangch
- * @return mixed
- */
- public function get_user_refresh_token($uid) {
- return $this->get('x_user_refresh_token:'.$uid);
- }
- /**
- * 设置用户token
- * @author: huangch
- */
- public function set_user_token($user) {
- $this->set('x_user_token:'.$user['id'], $user['token'],86400);
- $this->set('x_user_refresh_token:'.$user['id'], $user['refresh_token'],86400 * 180);
- }
- /**
- * 刷新用户token
- * @param $uid
- * @param $token
- * @param $refresh_token
- * @author: huangch
- */
- public function refresh_user_token($uid,$token,$refresh_token) {
- $this->set('x_user_token:'.$uid, $token,86400);
- $this->set('x_user_refresh_token:'.$uid, $refresh_token,86400 * 180);
- }
- /**
- * 小程序用户设置token
- * @param $user
- * @author: linch
- */
- public function set_mini_app_user_token($user) {
- $this->set('mini_app_user_token:' . $user['uid'], $user['token'], 3600);
- }
- /**
- * 小程序用户获取token
- * @param $uid
- * @author: linch
- */
- public function get_mini_app_user_token($uid) {
- return $this->get('mini_app_user_token:' . $uid);
- }
- }
|