error(); } $redis = new Redis(); $redisconfig = config("redis"); $redis->connect($redisconfig["host"], $redisconfig["port"]); $a = $redis->get("livebc_".$party_id); dump($a); } //直播间贡献值 public function show_livebc_jewel(){ $party_id = input('party_id'); if(empty($party_id)){ $this->error(); } $redis = new Redis(); $redisconfig = config("redis"); $redis->connect($redisconfig["host"], $redisconfig["port"]); $userModel = new \app\common\model\User(); // 获取条数 $num = 3; // 获取3条财富排行周记录 $getweek = $redis->zRevRange("livebc_jewel_to_".$party_id,0,-1,true); $getweek2 = $redis->zRevRange("livebc_jewel_get_".$party_id,0,0,true); $userList = $userModel->rankList($getweek); $userList2 = $userModel->rankList($getweek2); dump($getweek); dump($getweek2); dump($userList); dump($userList2); $avatarArr = []; if($userList) { foreach($userList as $k => $v) { $v["jewel"] > 0 && $avatarArr[] = $v["avatar"]; } // 加入缓存做备份 $redis->hSet("user_jewel_top3",$party_id,json_encode($avatarArr)); //$redis->hSet("livebc_jewel_top3",$party_id,json_encode($avatarArr)); } dump($avatarArr); } //清空直播间贡献值 public function clear(){ $party_id = input('party_id'); if(empty($party_id)){ $this->error(); } //清空房间排行榜 $redis = new Redis(); $redisconfig = config("redis"); $redis->connect($redisconfig["host"], $redisconfig["port"]); $redis->del('livebc_jewel_to_' . $party_id); $redis->del('livebc_jewel_get_' . $party_id); $redis->hDel("user_jewel_top3",$party_id); } }