1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add *Map commands where possible.

This commit is contained in:
Vladimir Mihailenco
2013-02-02 14:17:01 +02:00
parent dfde8211d4
commit 5a90e32c63
4 changed files with 293 additions and 26 deletions

View File

@ -425,6 +425,12 @@ func (c *Client) HGetAll(key string) *StringSliceReq {
return req
}
func (c *Client) HGetAllMap(key string) *StringStringMapReq {
req := NewStringStringMapReq("HGETALL", key)
c.Process(req)
return req
}
func (c *Client) HIncrBy(key, field string, incr int64) *IntReq {
req := NewIntReq("HINCRBY", key, field, strconv.FormatInt(incr, 10))
c.Process(req)
@ -784,6 +790,19 @@ func (c *Client) ZRangeWithScores(key string, start, stop int64) *StringSliceReq
return c.zRange(key, start, stop, true)
}
func (c *Client) ZRangeWithScoresMap(key string, start, stop int64) *StringFloatMapReq {
args := []string{
"ZRANGE",
key,
strconv.FormatInt(start, 10),
strconv.FormatInt(stop, 10),
"WITHSCORES",
}
req := NewStringFloatMapReq(args...)
c.Process(req)
return req
}
func (c *Client) zRangeByScore(
key string,
min, max string,
@ -815,6 +834,22 @@ func (c *Client) ZRangeByScoreWithScores(key string, min, max string, offset, co
return c.zRangeByScore(key, min, max, true, offset, count)
}
func (c *Client) ZRangeByScoreWithScoresMap(
key string, min, max string, offset, count int64) *StringFloatMapReq {
args := []string{"ZRANGEBYSCORE", key, min, max, "WITHSCORES"}
if offset != 0 || count != 0 {
args = append(
args,
"LIMIT",
strconv.FormatInt(offset, 10),
strconv.FormatInt(count, 10),
)
}
req := NewStringFloatMapReq(args...)
c.Process(req)
return req
}
func (c *Client) ZRank(key, member string) *IntReq {
req := NewIntReq("ZRANK", key, member)
c.Process(req)
@ -863,6 +898,13 @@ func (c *Client) ZRevRangeWithScores(key, start, stop string) *StringSliceReq {
return c.zRevRange(key, start, stop, true)
}
func (c *Client) ZRevRangeWithScoresMap(key, start, stop string) *StringFloatMapReq {
args := []string{"ZREVRANGE", key, start, stop, "WITHSCORES"}
req := NewStringFloatMapReq(args...)
c.Process(req)
return req
}
func (c *Client) zRevRangeByScore(key, start, stop string, withScores bool, offset, count int64) *StringSliceReq {
args := []string{"ZREVRANGEBYSCORE", key, start, stop}
if withScores {
@ -889,6 +931,22 @@ func (c *Client) ZRevRangeByScoreWithScores(key, start, stop string, offset, cou
return c.zRevRangeByScore(key, start, stop, false, offset, count)
}
func (c *Client) ZRevRangeByScoreWithScoresMap(
key, start, stop string, offset, count int64) *StringFloatMapReq {
args := []string{"ZREVRANGEBYSCORE", key, start, stop, "WITHSCORES"}
if offset != 0 || count != 0 {
args = append(
args,
"LIMIT",
strconv.FormatInt(offset, 10),
strconv.FormatInt(count, 10),
)
}
req := NewStringFloatMapReq(args...)
c.Process(req)
return req
}
func (c *Client) ZRevRank(key, member string) *IntReq {
req := NewIntReq("ZREVRANK", key, member)
c.Process(req)