Selaa lähdekoodia

Merge branch 'master' of http://git.huxiukeji.com/lizhen/xiaoyou

lizhen_gitee 6 kuukautta sitten
vanhempi
commit
e823de905b

+ 4 - 10
addons/faqueue/library/jobs/CheckRelegation.php

@@ -7,20 +7,15 @@ use addons\faqueue\model\FaqueueLog;
 use app\admin\model\AdminMessage;
 use app\admin\model\UserMessage;
 use app\common\library\weChat\weChatMp;
+use app\utils\RedisUtil;
 use think\Db;
 use think\Log;
 use think\queue\job;
 
 class CheckRelegation
 {
-    private $redis;
-
     function __construct()
     {
-        $redis = new \Redis();
-        $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"], 86400 * 31);
-        $this->redis = $redis;
     }
 
     public function fire(Job $job, $data)
@@ -38,7 +33,7 @@ class CheckRelegation
         //玩家当前贵族等级
         $userNoble = $user['noble'];
         $nobleDuetime = $user['noble_duetime'];
-        $userRenew2 = $this->redis->get('user_renew2_'.$user_id);
+        $userRenew2 = RedisUtil::getInstance('user_renew2',$user_id)->get();
         $getNobleLevelData = $this->getNobleLevelData($userNoble);
         if (empty($getNobleLevelData)) {
             $job->delete();
@@ -46,8 +41,7 @@ class CheckRelegation
         }
 
         $renew2 = $getNobleLevelData['renew2'];
-//        $this->redis->set('user_renew_'.$user_id,0);
-        $this->redis->set('user_renew2_'.$user_id,0);
+        RedisUtil::getInstance('user_renew2',$user_id)->setex(0,31 * 86400);
         $duetime = strtotime("+1 month",$nobleDuetime);
 
         //如果不是最大等级保级说明是重新回到该爵位,需扣除之前回到回到该爵位的消保
@@ -85,7 +79,7 @@ class CheckRelegation
      */
     private function getNobleLevelData($level_id)
     {
-        $getNobleLevelList = $this->redis->get('noble_level_list');
+        $getNobleLevelList = RedisUtil::getInstance('noble_level_list')->get();
         if (empty($getNobleLevelList)) return [];
         $getNobleLevelList = unserialize($getNobleLevelList);
         foreach ($getNobleLevelList as $v){

+ 2 - 2
application/api/controller/Gift.php

@@ -84,7 +84,7 @@ class Gift extends Api
     //聊天送礼物
     public function givegift_typing() {
         // 接口防并发
-        if (!$this->apiLimit(1, 1000)) {
+        if (!$this->apiLimit(1, 1)) {
             $this->error(__('Operation frequently'));
         }
 
@@ -245,7 +245,7 @@ class Gift extends Api
     public function givechatgift() {
         exit; //作废
         // 接口防并发
-        if (!$this->apiLimit(1, 1000)) {
+        if (!$this->apiLimit(1, 1)) {
             $this->error(__('Operation frequently'));
         }
 

+ 33 - 63
application/api/controller/Tenim.php

@@ -3,11 +3,11 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
+use app\utils\RedisUtil;
 use think\Request;
 use getusersig\getusersig;
 use tencentim\tencentim;
 use think\Db;
-use Redis;
 
 /**
  * 腾讯im接口
@@ -485,10 +485,7 @@ exit;
                 if($groupInfo["ErrorCode"] == 0) $groupsites[] = $groupInfo["GroupInfo"][0];
 
                 // 踢出用户在线组
-                $redis = new Redis();
-                $redisconfig = config("redis");
-                $redis->connect($redisconfig["host"], $redisconfig["port"]);
-                $redis->HDel("online_".$v["GroupId"],$user_id);
+                RedisUtil::getInstance('online',$v["GroupId"])->HDel($user_id);
             }
             // 强制下麦
             $this->downSite($user_id,$groupsites);
@@ -506,10 +503,7 @@ exit;
         $userInfo = \app\common\model\User::field("avatar")->where(["id"=>$user_id])->find();
         $userAvatar = isset($userInfo["avatar"])?$userInfo["avatar"]:"";
 
-        $redis = new Redis();
-        $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
-        $redisData = $redis->get("party_".$party_id);
+        $redisData = RedisUtil::getInstance('party',$party_id)->get();
         if(!$redisData) {
             return true;
         }
@@ -519,8 +513,7 @@ exit;
         $partyuser = isset($partyInfo["party_user"])?$partyInfo["party_user"]:"";
         if(is_array($partyuser)) foreach($partyuser as $k => $v) if($v === $userAvatar) unset($partyInfo["party_user"][$k]);
 
-        $redis->set("party_".$party_id,json_encode($partyInfo));
-
+        RedisUtil::getInstance('party',$party_id)->set(json_encode($partyInfo));
     }
 
 
@@ -531,10 +524,7 @@ exit;
         if (!$party_id || !$user_id) {
             return false;
         }
-        $redis = new Redis();
-        $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
-        $data=unserialize($redis->hGet("party_lineup",$party_id));
+        $data=unserialize(RedisUtil::getInstance('party_lineup')->hGet($party_id));
         // 更改红点排麦数量
         $num = 0;
         $send = false;
@@ -545,7 +535,7 @@ exit;
                 break;
             }
         }
-        $redis->hSet("party_lineup",$party_id,serialize($data));
+        RedisUtil::getInstance('party_lineup')->hSet($party_id,serialize($data));
 
         if($send) {
             is_array($data) &&  $num = count($data);
@@ -665,15 +655,11 @@ exit;
                 //没有UserId
             }elseif($input['EventType'] == 103){
                 //进入房间,主播role=20 观众role=21
-                $redis = new Redis();
-                $redisconfig = config("redis");
-                $redis->connect($redisconfig["host"], $redisconfig["port"]);
-
                 $userId = $input['EventInfo']['UserId'];
-                $redis->hSet("online_" . $roomId, $userId, $userId);
+                RedisUtil::getInstance('online',$roomId)->hSet($userId, $userId);
 
                 // 记录在线用户在房间情况
-                $redis->hSet("livingUser",$userId,$roomId);
+                RedisUtil::getInstance('livingUser')->hSet($userId,$roomId);
 
                 // 更新房间在线状态
                 $partyInfo = $redis->get("party_" . $roomId);
@@ -700,34 +686,30 @@ exit;
 
             }elseif($input['EventType'] == 104){
                 //退出房间,主播role=20 观众role=21
-                $redis = new Redis();
-                $redisconfig = config("redis");
-                $redis->connect($redisconfig["host"], $redisconfig["port"]);
-
                 $userId = $input['EventInfo']['UserId'];
-                $redis->HDel("online_" . $roomId, $userId);
+                RedisUtil::getInstance('online',$roomId)->HDel($userId);
 
                 // 扣除在线用户在房间情况
-                $redis->hDel("livingUser",$userId);
+                RedisUtil::getInstance('livingUser')->hDel($userId);
 
                 // 更新房间在线状态
-                $partyInfo = $redis->get("party_" . $roomId);
+                $partyInfo = RedisUtil::getInstance('party',$roomId)->get();
                 if ($partyInfo) {
                     $partyInfo = json_decode($partyInfo, true);
-                    $memCount = count($redis->hGetAll("online_" . $roomId));
+                    $memCount = count(RedisUtil::getInstance('online',$roomId)->hGetAll());
                     if ($memCount <= 0) {
                         $partyInfo["is_online"] = 0;
-                        $redis->set("party_" . $roomId, json_encode($partyInfo));
+                        RedisUtil::getInstance('party',$roomId)->set(json_encode($partyInfo));
                         \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
                     }
                 }
                 //
-                $liveInfo = $redis->get("livebc_" . $roomId);
+                $liveInfo = RedisUtil::getInstance('livebc',$roomId)->get();
                 if ($liveInfo) {
                     $liveInfo = json_decode($liveInfo, true);
                     if($input['EventInfo']['Role'] == 20){
                         $liveInfo["is_online"] = 0;
-                        $redis->set("livebc_" . $roomId, json_encode($liveInfo));
+                        RedisUtil::getInstance('livebc',$roomId)->set(json_encode($liveInfo));
                         \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
                         $rs_user = Db::name('user')->where('id',$userId)->update(['is_livebc'=>0]);
                     }
@@ -782,14 +764,11 @@ exit;
                     //\app\common\model\User::update(["is_live"=>0],["id"=>$info["To_Account"]]);
 
                     // 获取用户在派对直播间情况信息
-                    $redis = new Redis();
-                    $redisconfig = config("redis");
-                    $redis->connect($redisconfig["host"], $redisconfig["port"]);
-                    $livingUserPartyId = $redis->hGet("livingUser", $info["To_Account"]);
+                    $livingUserPartyId = RedisUtil::getInstance('livingUser')->hGet($info["To_Account"]);
                     if ($livingUserPartyId) {
                         // 扣除在线用户在房间情况
-                        $redis->hDel("livingUser", $info["To_Account"]);
-                        $redis->HDel("online_" . $livingUserPartyId, $info["To_Account"]);
+                        RedisUtil::getInstance('livingUser')->hDel( $info["To_Account"]);
+                        RedisUtil::getInstance('online',$livingUserPartyId)->HDel($info["To_Account"]);
                     }
 
                     // 获取用户所在群信息
@@ -805,10 +784,7 @@ exit;
                             if($groupInfo["ErrorCode"] == 0) $groupsites[] = $groupInfo["GroupInfo"][0];
 
                             // 踢出用户在线组
-                            $redis = new Redis();
-                            $redisconfig = config("redis");
-                            $redis->connect($redisconfig["host"], $redisconfig["port"]);
-                            $redis->HDel("online_".$v["GroupId"],$info["To_Account"]);
+                            RedisUtil::getInstance('online',$v["GroupId"])->HDel($info["To_Account"]);
 
                             // 更新麦位前四
                             $this->updatePosition($info["To_Account"],$v["GroupId"]);
@@ -817,24 +793,24 @@ exit;
                             $this->cancelLineup($info["To_Account"],$v["GroupId"]);
 
                             // 房间状态变更
-                            $partyInfo = $redis->get("party_".$v["GroupId"]);
+                            $partyInfo = RedisUtil::getInstance('party',$v["GroupId"])->get();
                             if($partyInfo) {
                                 $partyInfo = json_decode($partyInfo,true);
-                                $memCount = count($redis->hGetAll("online_".$v["GroupId"]));
+                                $memCount = count(RedisUtil::getInstance('online',$v["GroupId"])->hGetAll());
                                 if($memCount <= 0) {
                                     $partyInfo["is_online"] = 0;
-                                    $redis->set("party_".$v["GroupId"],json_encode($partyInfo));
+                                    RedisUtil::getInstance('party',$v["GroupId"])->set(json_encode($partyInfo));
                                     \app\common\model\Party::update(["is_online"=>0],["id"=>$v["GroupId"]]);
                                 }
                             }
 
-                            $liveInfo = $redis->get("live_".$v["GroupId"]);
+                            $liveInfo = RedisUtil::getInstance('live',$v["GroupId"])->get();
                             if($liveInfo) {
                                 $liveInfo = json_decode($liveInfo,true);
-                                $memCount = count($redis->hGetAll("online_".$v["GroupId"]));
+                                $memCount = count(RedisUtil::getInstance('online',$v["GroupId"])->hGetAll());
                                 if($memCount <= 0) {
                                     $liveInfo["is_online"] = 0;
-                                    $redis->set("live_".$v["GroupId"],json_encode($liveInfo));
+                                    RedisUtil::getInstance('live',$v["GroupId"])->set(json_encode($liveInfo));
                                     \app\common\model\Party::update(["is_online"=>0],["id"=>$v["GroupId"]]);
                                 }
                             }
@@ -847,12 +823,9 @@ exit;
                 }
                 break;
 //            case 'Group.CallbackAfterNewMemberJoin': // 新成员入群
-//                $redis = new Redis();
-//                $redisconfig = config("redis");
-//                $redis->connect($redisconfig["host"], $redisconfig["port"]);
 //                $members = $input["NewMemberList"];
 //                if($members) foreach($members as $k => $v) {
-//                    $redis->hSet("online_".$input["GroupId"],$v["Member_Account"],$v["Member_Account"]);
+//                    RedisUtil::getInstance('online',$input["GroupId"])->hSet($v["Member_Account"],$v["Member_Account"]);
 //                    // 更新房间在线状态
 //                    $party_id = $input["GroupId"];
 //                    $partyInfo = $redis->get("party_".$party_id);
@@ -872,33 +845,30 @@ exit;
 //                echo json_encode($res);
 //                break;
 //            case 'Group.CallbackAfterMemberExit': // 成员离开
-//                $redis = new Redis();
-//                $redisconfig = config("redis");
-//                $redis->connect($redisconfig["host"], $redisconfig["port"]);
 //                $members = $input["ExitMemberList"];
 //                if($members) foreach($members as $k => $v) {
-//                    $redis->HDel("online_".$input["GroupId"],$v["Member_Account"]);
+//                    RedisUtil::getInstance('online',$input["GroupId"])->HDel($v["Member_Account"]);
 //                }
 //                // 更新房间在线状态
 //                $party_id = $input["GroupId"];
-//                $partyInfo = $redis->get("party_".$party_id);
+//                $partyInfo = RedisUtil::getInstance('party',$party_id)->get();
 //                if($partyInfo) {
 //                    $partyInfo = json_decode($partyInfo,true);
-//                    $memCount = count($redis->hGetAll("online_".$party_id));
+//                    $memCount = count(RedisUtil::getInstance('online',$party_id)->hGetAll());
 //                    if($memCount <= 0) {
 //                        $partyInfo["is_online"] = 0;
-//                        $redis->set("party_".$party_id,json_encode($partyInfo));
+//                        RedisUtil::getInstance('party',$party_id)->set(json_encode($partyInfo));
 //                        \app\common\model\Party::update(["is_online"=>0],["id"=>$party_id]);
 //                    }
 //                }
 //
-//                $liveInfo = $redis->get("live_".$party_id);
+//                $liveInfo = RedisUtil::getInstance('live',$party_id)->get();
 //                if($liveInfo) {
 //                    $liveInfo = json_decode($liveInfo,true);
-//                    $memCount = count($redis->hGetAll("online_".$party_id));
+//                    $memCount = count(RedisUtil::getInstance('online',$party_id)->hGetAll());
 //                    if($memCount <= 0) {
 //                        $liveInfo["is_online"] = 0;
-//                        $redis->set("live_".$party_id,json_encode($liveInfo));
+//                        RedisUtil::getInstance('live',$party_id)->set(json_encode($liveInfo));
 //                        \app\common\model\Party::update(["is_online"=>0],["id"=>$party_id]);
 //                    }
 //                }

+ 1 - 1
application/api/controller/Topicdongtai.php

@@ -553,7 +553,7 @@ class Topicdongtai extends Api
     //动态赠送礼物
     public function givegiftdongtai() {
         // 接口防并发
-        if (!$this->apiLimit(1, 1000)) {
+        if (!$this->apiLimit(1, 1)) {
             $this->error(__('Operation frequently'));
         }
 

+ 1 - 1
application/api/controller/User.php

@@ -1199,7 +1199,7 @@ class User extends Api
     public function changeDeviceIp()
     {
         // 接口防并发
-        if (!$this->apiLimit(1, 5000)) {
+        if (!$this->apiLimit(1, 5)) {
             return ;
         }
 

+ 4 - 6
application/api/controller/Usercenter.php

@@ -3,6 +3,7 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
+use app\utils\RedisUtil;
 use think\Cache;
 use think\Db;
 use app\common\model\wallet;
@@ -791,10 +792,7 @@ class Usercenter extends Api
     public function getMyUserInfo() {
         $userInfo = $this->auth->getUserinfo();
         //当月消费金额
-        $redis = new Redis();
-        $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
-        $user_renew2 = $redis->get('user_renew2_'.$this->auth->id);
+        $user_renew2 = RedisUtil::getInstance('user_renew2',$this->auth->id)->get();
         $userInfo['user_renew2'] = empty($user_renew2)?0:intval($user_renew2);
 
         $this->success("获取成功!",$userInfo);
@@ -892,7 +890,7 @@ class Usercenter extends Api
     //开通守护
     public function addguard() {
         // 接口防并发
-        if (!$this->apiLimit(1, 1000)) {
+        if (!$this->apiLimit(1, 1)) {
             $this->error(__('Operation frequently'));
         }
 
@@ -1954,7 +1952,7 @@ $resArray['money'] = $money;  //返回给前端的计算结果
     //男性非会员解锁聊天
     public function unlockchat() {
         // 接口防并发
-        if (!$this->apiLimit(1, 1000)) {
+        if (!$this->apiLimit(1, 1)) {
             $this->error(__('Operation frequently'));
         }
         //男性非会员是否已开通聊天

+ 1 - 1
application/api/controller/Userfollow.php

@@ -94,7 +94,7 @@ class Userfollow extends Api
     //关注某人
     public function follow_one(){
         // 接口防并发
-        if (!$this->apiLimit(1, 1000)) {
+        if (!$this->apiLimit(1, 1)) {
             $this->error(__('Operation frequently'));
         }
 

+ 5 - 15
application/common/controller/Api.php

@@ -3,6 +3,7 @@
 namespace app\common\controller;
 
 use app\common\library\Auth;
+use app\utils\RedisUtil;
 use think\Config;
 use think\exception\HttpResponseException;
 use think\exception\ValidateException;
@@ -446,11 +447,11 @@ class Api
     /**
      * 接口请求限制
      * @param int $apiLimit
-     * @param int $apiLimitTime
+     * @param int $apiLimitTime 单位:秒(s)
      * @param string $key
      * @return bool | true:通过 false:拒绝
      */
-    public function apiLimit($apiLimit = 1, $apiLimitTime = 1000, $key = '')
+    public function apiLimit($apiLimit = 1, $apiLimitTime = 1, $key = '')
     {
         $userId = $this->auth->id;
         $controller = request()->controller();
@@ -460,19 +461,8 @@ class Api
             $key = strtolower($controller) . '_' . strtolower($action) . '_' . $userId;
         }
 
-        $redis = new Redis();
-        $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
-        $check = $redis->exists($key);
-        if ($check) {
-            $redis->incr($key);
-            $count = $redis->get($key);
-            if ($count > $apiLimit) {
-                return false;
-            }
-        } else {
-            $redis->incr($key);
-            $redis->pExpire($key, $apiLimitTime);
+        if (!RedisUtil::getInstance($key)->tryTimes($apiLimit,intval($apiLimitTime/1000))){
+            return false;
         }
         return true;
     }

+ 11 - 17
application/common/controller/RedisLeaderboard.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\common\controller;
 
+use app\utils\RedisUtil;
 use Redis;
 
 /**
@@ -10,12 +11,6 @@ use Redis;
  */
 class RedisLeaderboard
 {
-
-    /**
-     *
-     * @var object redis client
-     */
-    private $redis;
     /**
      *
      * @var string 放置排行榜的key
@@ -29,8 +24,6 @@ class RedisLeaderboard
      */
     public function __construct($leaderboard = '') {
 
-        $this->redis = new \Redis();
-        $this->redis->connect('127.0.0.1');
         $this->leaderboard = $leaderboard;
     }
     /**
@@ -49,7 +42,7 @@ class RedisLeaderboard
      */
     public function addLeaderboard($node, $count = 1)
     {
-        return $this->redis->zAdd($this->leaderboard, $count, $node);
+        return RedisUtil::getInstance($this->leaderboard)->zAdd($count, $node);
     }
     /**
      * 给出对应的排行榜
@@ -62,9 +55,9 @@ class RedisLeaderboard
     public function getLeadboard($number, $asc = true, $withscores = false,$callback = null)
     {
         if ($asc) {
-            $nowLeadboard =  $this->redis->zRevRange($this->leaderboard, 0, $number -1, $withscores);//按照高分数顺序排行;
+            $nowLeadboard =  RedisUtil::getInstance($this->leaderboard)->zRevRange(0, $number -1, $withscores);//按照高分数顺序排行;
         } else {
-            $nowLeadboard =  $this->redis->zRange($this->leaderboard, 0, $number -1, $withscores);//按照低分数顺序排行;
+            $nowLeadboard =  RedisUtil::getInstance($this->leaderboard)->zRange(0, $number -1, $withscores);//按照低分数顺序排行;
         }
 
 
@@ -77,17 +70,18 @@ class RedisLeaderboard
     }
     /**
      * 获取给定节点的排名
-     * @param string $node 对应的节点的key名
-     * @param string $asc 是否按照分数大小正序排名, true的情况下分数越大,排名越高
-     * @return 节点排名,根据$asc排序,true的话,第一高分为0,false的话第一低分为0
+     * @param $node 对应的节点的key名
+     * @param $asc 是否按照分数大小正序排名, true的情况下分数越大,排名越高
+     * @return array|false|int|Redis 节点排名,根据$asc排序,true的话,第一高分为0,false的话第一低分为0
+     * @throws \Exception
      */
     public function getNodeRank($node, $asc = true)
     {
         if ($asc) {
             //zRevRank 分数最高的排行为0,所以需要加1位
-            return $this->redis->zRevRank($this->leaderboard, $node);
+            return RedisUtil::getInstance($this->leaderboard)->zRevRank($node);
         } else {
-            return $this->redis->zRank($this->leaderboard, $node);
+            return RedisUtil::getInstance($this->leaderboard)->zRank($node);
         }
     }
 
@@ -95,7 +89,7 @@ class RedisLeaderboard
      * 计算给定的一个或多个有序集的并集
      */
     public function getZunionstore() {
-        $this->redis->zUnionStore();
+        RedisUtil::getInstance('')->zUnionStore();
     }
 
 }

+ 2 - 4
application/common/model/Party.php

@@ -2,6 +2,7 @@
 
 namespace app\common\model;
 
+use app\utils\RedisUtil;
 use think\Model;
 use Redis;
 /**
@@ -23,15 +24,12 @@ class Party extends Model
     public function getPatyInfoByPartyId($party_id,$room_type,$type_id,$is_recommend,$all,$start = 0,$end = 9,$index) {
         if(!$party_id) return false;
         // 判断派对是否存在
-        $redis = new Redis();
-        $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
         if(!is_array($party_id)) {
             return [];
         }
         $redisPartyInfo = [];
         foreach($party_id as $k => $v) {
-            $getredisPartyInfo = $redis->get($room_type.'_'.$k);
+            $getredisPartyInfo = RedisUtil::getInstance($room_type,$k)->get();
 
             $foreachData = json_decode($getredisPartyInfo,true);
 

+ 49 - 9
application/utils/RedisUtil.php

@@ -26,7 +26,7 @@ class RedisUtil
         }
         $this->options = config('redis');
         $func          = $this->options['persistent'] ? 'pconnect' : 'connect';// 判断是否长链接
-        $this->Redis   = new \Redis;
+        $this->Redis   = new \Redis();
         $redis         = $this->Redis->$func($this->options['host'], $this->options['port'], $this->options['timeout']);
         if (!$redis) {
             throw new \BadFunctionCallException('connection fail: redis');
@@ -181,6 +181,15 @@ class RedisUtil
         return $redis->setex($key, $second, $value);
     }
 
+    public function set($value, $options = null)
+    {
+        $redis = $this->Redis;
+
+        $key = $this->Key;
+
+        return $redis->set($key, $value, $options);
+    }
+
     public function get()
     {
         $redis = $this->Redis;
@@ -277,50 +286,81 @@ class RedisUtil
     }
 
     // 递增返回
-    public function zRange($start_score = 0, $end_score = -1)
+    public function zRange($start_score = 0, $end_score = -1, $options = null)
     {
         $redis = $this->Redis;
 
         $key = $this->Key;
 
-        return $redis->zrange($key, $start_score, $end_score);
+        return $redis->zrange($key, $start_score, $end_score,$options);
     }
 
     // 递减返回
-    public function zRevRange($start_score = 0, $end_score = -1)
+    public function zRevRange($start_score = 0, $end_score = -1, $options = null)
     {
         $redis = $this->Redis;
 
         $key = $this->Key;
 
-        return $redis->zRevRange($key, $start_score, $end_score);
+        return $redis->zRevRange($key, $start_score, $end_score,$options);
     }
 
-    public function hSet($field, $value)
+    public function zRevRank($start, $end, $scores = null)
     {
         $redis = $this->Redis;
+
         $key = $this->Key;
+
+        return $redis->zRevRange($key, $start, $end,$scores);
+    }
+
+    public function zRank($member)
+    {
+        $redis = $this->Redis;
+
+        $key = $this->Key;
+
+        return $redis->zRank($key, $member);
+    }
+
+    public function zUnionStore($output, $zSetKeys, ?array $weights = null, $aggregateFunction = null)
+    {
+        $redis = $this->Redis;
+        return $redis->zUnionStore($output, $zSetKeys, $weights, $aggregateFunction);
+    }
+
+    public function hSet($field, $value)
+    {
+        $redis = $this->Redis;
+        $key   = $this->Key;
         return $redis->hset($key, $field, $value);
     }
 
     public function hKeys()
     {
         $redis = $this->Redis;
-        $key = $this->Key;
+        $key   = $this->Key;
         return $redis->hkeys($key);
     }
 
     public function hGet($field)
     {
         $redis = $this->Redis;
-        $key = $this->Key;
+        $key   = $this->Key;
         return $redis->hget($key, $field);
     }
 
     public function hDel($field)
     {
         $redis = $this->Redis;
-        $key = $this->Key;
+        $key   = $this->Key;
         return $redis->hdel($key, $field);
     }
+
+    public function hGetAll()
+    {
+        $redis = $this->Redis;
+        $key   = $this->Key;
+        return $redis->hGetAll($key);
+    }
 }