Commit 4a487b1f by xuzhenhao

增加了redis工具库中的方法

1 parent f73ac45f
Showing with 1 additions and 9 deletions
...@@ -398,7 +398,6 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -398,7 +398,6 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
err = errors.New("用户未提交分数") err = errors.New("用户未提交分数")
return nil, "105201", err return nil, "105201", err
} }
log.Println(score)
scoreString := "(" + string(score.([]uint8)) scoreString := "(" + string(score.([]uint8))
// 获取当前用户前x位和后x位的排名数据 // 获取当前用户前x位和后x位的排名数据
var prerankIndex int var prerankIndex int
...@@ -427,7 +426,6 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -427,7 +426,6 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
} else { } else {
resIndex = prerankIndex + 1 resIndex = prerankIndex + 1
} }
log.Println("nextrankIndex:", nextrankIndex, "prerankIndex:", prerankIndex, "sorceorder:", sorceorder)
// 排序 // 排序
var strList, strList1, strList2 []string var strList, strList1, strList2 []string
if sorceorder == "1" { if sorceorder == "1" {
...@@ -436,7 +434,6 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -436,7 +434,6 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
if err != nil { if err != nil {
log.Println("zrangebyscore:", err) log.Println("zrangebyscore:", err)
} }
log.Println("strList1:", strList1)
//将结果倒序 //将结果倒序
var tempList []string var tempList []string
for i := len(strList1) - 1; i >= 0; i -= 2 { for i := len(strList1) - 1; i >= 0; i -= 2 {
...@@ -444,7 +441,6 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -444,7 +441,6 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
tempList = append(tempList, strList1[i]) tempList = append(tempList, strList1[i])
} }
strList1 = tempList strList1 = tempList
log.Println("tempList : ", strList1)
} }
if nextrankIndex != 0 { if nextrankIndex != 0 {
strList2, err = RedisZRevRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "-inf", "true", 0, nextrankIndex) strList2, err = RedisZRevRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "-inf", "true", 0, nextrankIndex)
...@@ -472,22 +468,18 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -472,22 +468,18 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
} else if sorceorder == "0" { } else if sorceorder == "0" {
if prerankIndex != 0 { if prerankIndex != 0 {
strList1, err = RedisZRevRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "-inf", "true", 0, prerankIndex) strList1, err = RedisZRevRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "-inf", "true", 0, prerankIndex)
log.Println("strList1 : ", strList1)
//将结果倒序 //将结果倒序
var tempList []string var tempList []string
log.Println(len(strList1))
for i := len(strList1) - 1; i >= 0; i -= 2 { for i := len(strList1) - 1; i >= 0; i -= 2 {
tempList = append(tempList, strList1[i-1]) tempList = append(tempList, strList1[i-1])
tempList = append(tempList, strList1[i]) tempList = append(tempList, strList1[i])
} }
strList1 = tempList strList1 = tempList
log.Println("tempList : ", strList1)
} }
if nextrankIndex != 0 { if nextrankIndex != 0 {
strList2, err = RedisZRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "+inf", "true", 0, nextrankIndex) strList2, err = RedisZRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "+inf", "true", 0, nextrankIndex)
log.Println("strList2 : ", strList2)
} }
if len(strList1) == 0 { if len(strList1) == 0 {
strList = append(strList, "ice_gametop:uid:"+uid+":gtid:"+gtid+":gid:"+gid+":toptype:"+toptype+":mykey") strList = append(strList, "ice_gametop:uid:"+uid+":gtid:"+gtid+":gid:"+gid+":toptype:"+toptype+":mykey")
...@@ -547,7 +539,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -547,7 +539,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
return nil, rank.(string), err return nil, rank.(string), err
} }
igt[s].RankIndex = int(count.(int64)) - 1 - rank.(int) igt[s].RankIndex = int(count.(int64)) - rank.(int)
igt[s].MyKey = strList[i+1] igt[s].MyKey = strList[i+1]
//查询储存昵称以及头像url的redis //查询储存昵称以及头像url的redis
resultstr, err = RedisGetKV(redisConn, "GUID:"+igt[s].UID) resultstr, err = RedisGetKV(redisConn, "GUID:"+igt[s].UID)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!