Skip to content

Commit 8648971

Browse files
authored
Merge pull request #1899 from alexus1024/master
Add support for BLMove command
2 parents fddf086 + f36093a commit 8648971

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

commands.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ type Cmdable interface {
195195
RPush(ctx context.Context, key string, values ...interface{}) *IntCmd
196196
RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
197197
LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd
198+
BLMove(ctx context.Context, source, destination, srcpos, destpos string, timeout time.Duration) *StringCmd
198199

199200
SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd
200201
SCard(ctx context.Context, key string) *IntCmd
@@ -1494,6 +1495,13 @@ func (c cmdable) LMove(ctx context.Context, source, destination, srcpos, destpos
14941495
return cmd
14951496
}
14961497

1498+
func (c cmdable) BLMove(ctx context.Context, source, destination, srcpos, destpos string, timeout time.Duration) *StringCmd {
1499+
cmd := NewStringCmd(ctx, "blmove", source, destination, srcpos, destpos, formatSec(ctx, timeout))
1500+
cmd.setReadTimeout(timeout)
1501+
_ = c(ctx, cmd)
1502+
return cmd
1503+
}
1504+
14971505
//------------------------------------------------------------------------------
14981506

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

commands_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,6 +2372,27 @@ var _ = Describe("Commands", func() {
23722372
Expect(lRange.Err()).NotTo(HaveOccurred())
23732373
Expect(lRange.Val()).To(Equal([]string{"san"}))
23742374
})
2375+
It("should BLMove", func() {
2376+
rPush := client.RPush(ctx, "blmove1", "ichi")
2377+
Expect(rPush.Err()).NotTo(HaveOccurred())
2378+
Expect(rPush.Val()).To(Equal(int64(1)))
2379+
2380+
rPush = client.RPush(ctx, "blmove1", "ni")
2381+
Expect(rPush.Err()).NotTo(HaveOccurred())
2382+
Expect(rPush.Val()).To(Equal(int64(2)))
2383+
2384+
rPush = client.RPush(ctx, "blmove1", "san")
2385+
Expect(rPush.Err()).NotTo(HaveOccurred())
2386+
Expect(rPush.Val()).To(Equal(int64(3)))
2387+
2388+
blMove := client.BLMove(ctx, "blmove1", "lmove2", "RIGHT", "LEFT", time.Second)
2389+
Expect(blMove.Err()).NotTo(HaveOccurred())
2390+
Expect(blMove.Val()).To(Equal("san"))
2391+
2392+
lRange := client.LRange(ctx, "blmove2", 0, -1)
2393+
Expect(lRange.Err()).NotTo(HaveOccurred())
2394+
Expect(lRange.Val()).To(Equal([]string{"san"}))
2395+
})
23752396
})
23762397

23772398
Describe("sets", func() {

0 commit comments

Comments
 (0)