1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-12 14:21:52 +03:00

Implemented ZRangeByLex with tests.

This commit is contained in:
Jeff Pierce
2015-08-22 20:38:37 -07:00
parent 5710d68852
commit 2de07f2493
2 changed files with 49 additions and 3 deletions

View File

@ -1094,8 +1094,14 @@ type ZRangeByScore struct {
Offset, Count int64
}
func (c *commandable) zRangeByScore(key string, opt ZRangeByScore, withScores bool) *StringSliceCmd {
args := []interface{}{"ZRANGEBYSCORE", key, opt.Min, opt.Max}
func (c *commandable) zRangeByScore(key string, opt ZRangeByScore, withScores, isLex bool) *StringSliceCmd {
var zcmd string
if isLex {
zcmd = "ZRANGEBYLEX"
} else {
zcmd = "ZRANGEBYSCORE"
}
args := []interface{}{zcmd, key, opt.Min, opt.Max}
if withScores {
args = append(args, "WITHSCORES")
}
@ -1113,7 +1119,11 @@ func (c *commandable) zRangeByScore(key string, opt ZRangeByScore, withScores bo
}
func (c *commandable) ZRangeByScore(key string, opt ZRangeByScore) *StringSliceCmd {
return c.zRangeByScore(key, opt, false)
return c.zRangeByScore(key, opt, false, false)
}
func (c *commandable) ZRangeByLex(key string, opt ZRangeByScore) *StringSliceCmd {
return c.zRangeByScore(key, opt, false, true)
}
func (c *commandable) ZRangeByScoreWithScores(key string, opt ZRangeByScore) *ZSliceCmd {