|
|
@@ -205,11 +205,23 @@ class Events
|
|
|
//后台更改了数据,sock里的缓存强制更新一下,做到即时更新的效果
|
|
|
self::updatecache($client_id, $message['data']);
|
|
|
break;
|
|
|
+ case 'updateusercache':
|
|
|
+ //更新用户缓存信息
|
|
|
+ self::updateusercache($client_id, $message['data']);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //更新用户缓存信息
|
|
|
+ public static function updateusercache($client_id, $dataArray)
|
|
|
+ {
|
|
|
+ $uid = intval($dataArray['userid']);
|
|
|
+ self::getUserInfoCache($uid, 180, 0);
|
|
|
+ }
|
|
|
+
|
|
|
//强制更新缓存信息
|
|
|
public static function updatecache($client_id, $dataArray)
|
|
|
{
|
|
|
@@ -2197,14 +2209,18 @@ class Events
|
|
|
}
|
|
|
|
|
|
//缓存获取用户信息
|
|
|
- public static function getUserInfoCache($uid, $cacheTime = 180)
|
|
|
+ public static function getUserInfoCache($uid, $cacheTime = 180, $fcache = 1)
|
|
|
{
|
|
|
$uid = intval($uid);
|
|
|
$key = 'TmpUserInfo:' . $uid;
|
|
|
- $cache = self::$redis->hget($key, $uid);
|
|
|
- if ($cache && $cacheTime) {
|
|
|
- return json_decode($cache, true);
|
|
|
+
|
|
|
+ if ($fcache && $cacheTime) {
|
|
|
+ $cache = self::$redis->hget($key, $uid);
|
|
|
+ if ($cache) {
|
|
|
+ return json_decode($cache, true);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
$date = self::$db->select('*')->from('ws_accounts')->where("id= $uid ")->row();
|
|
|
self::$redis->hset($key, $uid, json_encode($date, 256));
|
|
|
self::$redis->EXPIRE($key, $cacheTime);
|