<?php

namespace app\index\controller;

use think\Db;
use Redis;
class Test
{

    public function redis(){

        $partyUserTop = $this->getPartyUserTop(26);
    }

    private function getPartyUserTop($party_id) {
        $redis = new Redis();
        $redisconfig = config("redis");
        $redis->connect($redisconfig["host"], $redisconfig["port"]);

        $userModel = new \app\common\model\User();
        // 获取条数
        $num = 100;
        // 获取3条财富排行周记录
        $getweek = $redis->zRevRange("livebc_jewel_to_".$party_id,0,$num-1,true);
        $userList = $userModel->rankList($getweek);

        dump($getweek);
        dump($userList);

        $heads = $redis->hGet("livebc_jewel_top3",$party_id);
        dump($heads);
    }

    public function clear(){
        $user_id = 26;
        //清空房间排行榜
        $redis = new Redis();
        $redisconfig = config("redis");
        $redis->connect($redisconfig["host"], $redisconfig["port"]);
        $redis->del('livebc_jewel_to_' . $user_id);
        $redis->hDel("livebc_jewel_top3",$user_id);
    }



}