Commit 7c3f1629 by xuzhenhao

增加了redis工具库中的方法

1 parent 162a8c15
......@@ -435,10 +435,16 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
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)
}
}
if prerankIndex != 0 {
strList2, err = RedisZRevRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "-inf", "true", 0, prerankIndex)
if err != nil {
log.Println("zrevrangebyscore:", err)
}
//将结果倒序
var tempList []string
for i := len(strList2); i < 0; i -= 2 {
......@@ -465,6 +471,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
} else if sorceorder == "0" {
if nextrankIndex != 0 {
strList1, err = RedisZRangeByScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, scoreString, "+inf", "true", 0, prerankIndex)
//将结果倒序
var tempList []string
for i := len(strList1); i < 0; i -= 2 {
......
......@@ -229,11 +229,11 @@ func RedisZRank(conn redis.Conn, key string, member string) (reply interface{},
*/
func RedisZRangeByScore(conn redis.Conn, key string, startScore string, endScore string, limit string, limitStart int, limitEnd int) (reply []string, err error) {
if limit == "true" {
res, err := RedisCommand(conn, "zrangebyscore", key, startScore, endScore, "withscore", "limit", limitStart, limitEnd)
res, err := RedisCommand(conn, "zrangebyscore", key, startScore, endScore, "withscores", "limit", limitStart, limitEnd)
reply, _ = redis.Strings(res, nil)
return reply, err
}
res, err := RedisCommand(conn, "zrangebyscore", key, startScore, endScore, "withscore")
res, err := RedisCommand(conn, "zrangebyscore", key, startScore, endScore, "withscores")
reply, _ = redis.Strings(res, nil)
return reply, err
}
......@@ -243,11 +243,11 @@ func RedisZRangeByScore(conn redis.Conn, key string, startScore string, endScore
*/
func RedisZRevRangeByScore(conn redis.Conn, key string, startScore string, endScore string, limit string, limitStart int, limitEnd int) (reply []string, err error) {
if limit == "true" {
res, err := RedisCommand(conn, "zrevrangebyscore", key, startScore, endScore, "withscore", "limit", limitStart, limitEnd)
res, err := RedisCommand(conn, "zrevrangebyscore", key, startScore, endScore, "withscores", "limit", limitStart, limitEnd)
reply, _ = redis.Strings(res, nil)
return reply, err
}
res, err := RedisCommand(conn, "zrevrangebyscore", key, startScore, endScore, "withscore")
res, err := RedisCommand(conn, "zrevrangebyscore", key, startScore, endScore, "withscores")
reply, _ = redis.Strings(res, nil)
return reply, err
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!