diff --git a/command.go b/command.go index da044caa..d357e922 100644 --- a/command.go +++ b/command.go @@ -3693,17 +3693,17 @@ func (cmd *MapStringStringSliceCmd) readReply(rd *proto.Reader) error { //------------------------------------------------------------------------------ -type ListElementCmd struct { +type KeyValuesCmd struct { baseCmd key string val []string } -var _ Cmder = (*ListElementCmd)(nil) +var _ Cmder = (*KeyValuesCmd)(nil) -func NewListElementCmd(ctx context.Context, args ...interface{}) *ListElementCmd { - return &ListElementCmd{ +func NewKeyValuesCmd(ctx context.Context, args ...interface{}) *KeyValuesCmd { + return &KeyValuesCmd{ baseCmd: baseCmd{ ctx: ctx, args: args, @@ -3711,24 +3711,24 @@ func NewListElementCmd(ctx context.Context, args ...interface{}) *ListElementCmd } } -func (cmd *ListElementCmd) SetVal(key string, val []string) { +func (cmd *KeyValuesCmd) SetVal(key string, val []string) { cmd.key = key cmd.val = val } -func (cmd *ListElementCmd) Val() (string, []string) { +func (cmd *KeyValuesCmd) Val() (string, []string) { return cmd.key, cmd.val } -func (cmd *ListElementCmd) Result() (string, []string, error) { +func (cmd *KeyValuesCmd) Result() (string, []string, error) { return cmd.key, cmd.val, cmd.err } -func (cmd *ListElementCmd) String() string { +func (cmd *KeyValuesCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *ListElementCmd) readReply(rd *proto.Reader) (err error) { +func (cmd *KeyValuesCmd) readReply(rd *proto.Reader) (err error) { if err = rd.ReadFixedArrayLen(2); err != nil { return err } diff --git a/commands.go b/commands.go index 61b1bac3..dd3cfd24 100644 --- a/commands.go +++ b/commands.go @@ -225,7 +225,7 @@ type Cmdable interface { LInsertBefore(ctx context.Context, key string, pivot, value interface{}) *IntCmd LInsertAfter(ctx context.Context, key string, pivot, value interface{}) *IntCmd LLen(ctx context.Context, key string) *IntCmd - LMPop(ctx context.Context, direction string, count int64, keys ...string) *ListElementCmd + LMPop(ctx context.Context, direction string, count int64, keys ...string) *KeyValuesCmd LPop(ctx context.Context, key string) *StringCmd LPopCount(ctx context.Context, key string, count int) *StringSliceCmd LPos(ctx context.Context, key string, value string, args LPosArgs) *IntCmd @@ -1467,7 +1467,7 @@ func (c cmdable) LIndex(ctx context.Context, key string, index int64) *StringCmd // LMPop Pops one or more elements from the first non-empty list key from the list of provided key names. // direction: left or right, count: > 0 // example: client.LMPop(ctx, "left", 3, "key1", "key2") -func (c cmdable) LMPop(ctx context.Context, direction string, count int64, keys ...string) *ListElementCmd { +func (c cmdable) LMPop(ctx context.Context, direction string, count int64, keys ...string) *KeyValuesCmd { args := make([]interface{}, 2+len(keys), 5+len(keys)) args[0] = "lmpop" args[1] = len(keys) @@ -1475,7 +1475,7 @@ func (c cmdable) LMPop(ctx context.Context, direction string, count int64, keys args[2+i] = key } args = append(args, strings.ToLower(direction), "count", count) - cmd := NewListElementCmd(ctx, args...) + cmd := NewKeyValuesCmd(ctx, args...) _ = c(ctx, cmd) return cmd } diff --git a/commands_test.go b/commands_test.go index 95fb2146..ba06a7c7 100644 --- a/commands_test.go +++ b/commands_test.go @@ -2279,25 +2279,25 @@ var _ = Describe("Commands", func() { err = client.LPush(ctx, "list2", "a", "b", "c", "d", "e").Err() Expect(err).NotTo(HaveOccurred()) - key, elems, err := client.LMPop(ctx, "left", 3, "list1", "list2").Result() + key, val, err := client.LMPop(ctx, "left", 3, "list1", "list2").Result() Expect(err).NotTo(HaveOccurred()) Expect(key).To(Equal("list1")) - Expect(elems).To(Equal([]string{"five", "four", "three"})) + Expect(val).To(Equal([]string{"five", "four", "three"})) - key, elems, err = client.LMPop(ctx, "right", 3, "list1", "list2").Result() + key, val, err = client.LMPop(ctx, "right", 3, "list1", "list2").Result() Expect(err).NotTo(HaveOccurred()) Expect(key).To(Equal("list1")) - Expect(elems).To(Equal([]string{"one", "two"})) + Expect(val).To(Equal([]string{"one", "two"})) - key, elems, err = client.LMPop(ctx, "left", 1, "list1", "list2").Result() + key, val, err = client.LMPop(ctx, "left", 1, "list1", "list2").Result() Expect(err).NotTo(HaveOccurred()) Expect(key).To(Equal("list2")) - Expect(elems).To(Equal([]string{"e"})) + Expect(val).To(Equal([]string{"e"})) - key, elems, err = client.LMPop(ctx, "right", 10, "list1", "list2").Result() + key, val, err = client.LMPop(ctx, "right", 10, "list1", "list2").Result() Expect(err).NotTo(HaveOccurred()) Expect(key).To(Equal("list2")) - Expect(elems).To(Equal([]string{"a", "b", "c", "d"})) + Expect(val).To(Equal([]string{"a", "b", "c", "d"})) err = client.LMPop(ctx, "left", 10, "list1", "list2").Err() Expect(err).To(Equal(redis.Nil))