Commit 8fd26820 by xuzhenhao

增加了redis工具库中的方法

1 parent 4b0a25fc
Showing with 17 additions and 16 deletions
......@@ -432,12 +432,19 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
log.Println("nextrankIndex:", nextrankIndex, "prerankIndex:", prerankIndex, "sorceorder:", sorceorder)
// 排序
var strList, strList1, strList2 []string
if sorceorder == "0" {
if sorceorder == "1" {
if nextrankIndex != 0 {
strList1, err = RedisZRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "+inf", "true", 0, nextrankIndex)
if err != nil {
log.Println("zrangebyscore:", err)
}
//将结果倒序
var tempList []string
for i := len(strList1); i < 0; i -= 2 {
tempList = append(tempList, strList1[i-1])
tempList = append(tempList, strList1[i])
}
strList1 = tempList
log.Println("strList1 : ", strList1)
}
if prerankIndex != 0 {
......@@ -445,13 +452,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
if err != nil {
log.Println("zrevrangebyscore:", err)
}
//将结果倒序
var tempList []string
for i := len(strList2); i < 0; i -= 2 {
tempList = append(tempList, strList2[i-1])
tempList = append(tempList, strList2[i])
}
strList2 = tempList
log.Println("strList2 : ", strList2)
}
if len(strList2) == 0 {
......@@ -469,21 +470,21 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
}
}
} else if sorceorder == "1" {
} else if sorceorder == "0" {
if nextrankIndex != 0 {
strList1, err = RedisZRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "+inf", "true", 0, prerankIndex)
log.Println("strList1 : ", strList1)
//将结果倒序
var tempList []string
for i := len(strList1); i < 0; i -= 2 {
tempList = append(tempList, strList1[i-1])
tempList = append(tempList, strList1[i])
}
strList1 = tempList
}
if prerankIndex != 0 {
strList2, err = RedisZRevRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "-inf", "true", 0, nextrankIndex)
//将结果倒序
var tempList []string
for i := len(strList2); i < 0; i -= 2 {
tempList = append(tempList, strList2[i-1])
tempList = append(tempList, strList2[i])
}
strList2 = tempList
log.Println("strList2 : ", strList2)
}
if len(strList1) == 0 {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!