Skip to content

Commit ef410de

Browse files
committed
Merge branch 'master' of github.com:go-redis/redis
2 parents 91cbbda + a47d2c2 commit ef410de

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

commands.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ func appendArg(dst []interface{}, arg interface{}) []interface{} {
6767
dst = append(dst, k, v)
6868
}
6969
return dst
70+
case map[string]string:
71+
for k, v := range arg {
72+
dst = append(dst, k, v)
73+
}
74+
return dst
7075
default:
7176
return append(dst, arg)
7277
}
@@ -186,6 +191,7 @@ type Cmdable interface {
186191
RPopLPush(ctx context.Context, source, destination string) *StringCmd
187192
RPush(ctx context.Context, key string, values ...interface{}) *IntCmd
188193
RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
194+
LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd
189195

190196
SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd
191197
SCard(ctx context.Context, key string) *IntCmd
@@ -1426,6 +1432,12 @@ func (c cmdable) RPushX(ctx context.Context, key string, values ...interface{})
14261432
return cmd
14271433
}
14281434

1435+
func (c cmdable) LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd {
1436+
cmd := NewStringCmd(ctx, "lmove", source, destination, srcpos, destpos)
1437+
_ = c(ctx, cmd)
1438+
return cmd
1439+
}
1440+
14291441
//------------------------------------------------------------------------------
14301442

14311443
func (c cmdable) SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd {

commands_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,28 @@ var _ = Describe("Commands", func() {
23172317
Expect(lRange.Err()).NotTo(HaveOccurred())
23182318
Expect(lRange.Val()).To(Equal([]string{}))
23192319
})
2320+
2321+
It("should LMove", func() {
2322+
rPush := client.RPush(ctx, "lmove1", "ichi")
2323+
Expect(rPush.Err()).NotTo(HaveOccurred())
2324+
Expect(rPush.Val()).To(Equal(int64(1)))
2325+
2326+
rPush = client.RPush(ctx, "lmove1", "ni")
2327+
Expect(rPush.Err()).NotTo(HaveOccurred())
2328+
Expect(rPush.Val()).To(Equal(int64(2)))
2329+
2330+
rPush = client.RPush(ctx, "lmove1", "san")
2331+
Expect(rPush.Err()).NotTo(HaveOccurred())
2332+
Expect(rPush.Val()).To(Equal(int64(3)))
2333+
2334+
lMove := client.LMove(ctx, "lmove1", "lmove2", "RIGHT", "LEFT")
2335+
Expect(lMove.Err()).NotTo(HaveOccurred())
2336+
Expect(lMove.Val()).To(Equal("san"))
2337+
2338+
lRange := client.LRange(ctx, "lmove2", 0, -1)
2339+
Expect(lRange.Err()).NotTo(HaveOccurred())
2340+
Expect(lRange.Val()).To(Equal([]string{"san"}))
2341+
})
23202342
})
23212343

23222344
Describe("sets", func() {

0 commit comments

Comments
 (0)