数据缓存处理
This commit is contained in:
@@ -1061,7 +1061,7 @@ class Room extends Model
|
||||
//各种房间类型的具体信息 在各个类型中获取 把下面有获取房间类型中的状态等信息的信息 放到各自的类型中去 这里只根据类型调用相关的就行
|
||||
public function join_room($user_id, $room_id, $password) {
|
||||
//房间基础信息先从缓存获取
|
||||
$room = Cache::get('room_info_' . $room_id);
|
||||
$room = json_decode(Cache::get('room_info_' . $room_id));
|
||||
if(!$room){
|
||||
$room = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||
$room['is_use_code'] = 0;
|
||||
@@ -1070,7 +1070,7 @@ class Room extends Model
|
||||
$room['is_use_code'] = 1;
|
||||
$room['room_number'] = $liang;
|
||||
}
|
||||
Cache::set('room_info_' . $room_id, $room, 7200);
|
||||
Cache::set('room_info_' . $room_id, json_encode($room), 7200);
|
||||
}
|
||||
|
||||
if(isset($room['password']) && $user_id != $room['user_id']){
|
||||
@@ -1081,11 +1081,11 @@ class Room extends Model
|
||||
|
||||
//房主信息
|
||||
//先从缓存中获取
|
||||
$room_owner = Cache::get('room_owner_' . $room_id);
|
||||
$room_owner = json_decode(Cache::get('room_owner_' . $room_id));
|
||||
if(!$room_owner){
|
||||
$room_owner = db::name('user')->where('id', $room['user_id'])->field('id as user_id,user_code,sex,nickname,avatar')->find();
|
||||
$room_owner['user_code'] = model('api/Decorate')->user_decorate_detail($room['user_id'],6);
|
||||
Cache::set('room_owner_' . $room_id, $room_owner, 7200);
|
||||
Cache::set('room_owner_' . $room_id, json_encode($room_owner), 7200);
|
||||
}
|
||||
|
||||
$room_type = $this->get_room_type($room_id);
|
||||
|
||||
Reference in New Issue
Block a user