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

Sort can return nil reply. Fixes #246.

This commit is contained in:
Vladimir Mihailenco
2016-01-22 12:29:23 +02:00
parent dd1ac33826
commit 3ed364e92a
3 changed files with 68 additions and 16 deletions

View File

@ -270,7 +270,7 @@ type Sort struct {
Store string
}
func (c *commandable) Sort(key string, sort Sort) *StringSliceCmd {
func (sort *Sort) args(key string) []interface{} {
args := []interface{}{"SORT", key}
if sort.By != "" {
args = append(args, "BY", sort.By)
@ -290,7 +290,17 @@ func (c *commandable) Sort(key string, sort Sort) *StringSliceCmd {
if sort.Store != "" {
args = append(args, "STORE", sort.Store)
}
cmd := NewStringSliceCmd(args...)
return args
}
func (c *commandable) Sort(key string, sort Sort) *StringSliceCmd {
cmd := NewStringSliceCmd(sort.args(key)...)
c.Process(cmd)
return cmd
}
func (c *commandable) SortInterfaces(key string, sort Sort) *SliceCmd {
cmd := NewSliceCmd(sort.args(key)...)
c.Process(cmd)
return cmd
}