forked from mirror/redis
Merge branch 'master' of github.com:go-redis/redis
This commit is contained in:
commit
ef410de385
12
commands.go
12
commands.go
|
@ -67,6 +67,11 @@ func appendArg(dst []interface{}, arg interface{}) []interface{} {
|
||||||
dst = append(dst, k, v)
|
dst = append(dst, k, v)
|
||||||
}
|
}
|
||||||
return dst
|
return dst
|
||||||
|
case map[string]string:
|
||||||
|
for k, v := range arg {
|
||||||
|
dst = append(dst, k, v)
|
||||||
|
}
|
||||||
|
return dst
|
||||||
default:
|
default:
|
||||||
return append(dst, arg)
|
return append(dst, arg)
|
||||||
}
|
}
|
||||||
|
@ -186,6 +191,7 @@ type Cmdable interface {
|
||||||
RPopLPush(ctx context.Context, source, destination string) *StringCmd
|
RPopLPush(ctx context.Context, source, destination string) *StringCmd
|
||||||
RPush(ctx context.Context, key string, values ...interface{}) *IntCmd
|
RPush(ctx context.Context, key string, values ...interface{}) *IntCmd
|
||||||
RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
|
RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
|
||||||
|
LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd
|
||||||
|
|
||||||
SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd
|
SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd
|
||||||
SCard(ctx context.Context, key string) *IntCmd
|
SCard(ctx context.Context, key string) *IntCmd
|
||||||
|
@ -1426,6 +1432,12 @@ func (c cmdable) RPushX(ctx context.Context, key string, values ...interface{})
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c cmdable) LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd {
|
||||||
|
cmd := NewStringCmd(ctx, "lmove", source, destination, srcpos, destpos)
|
||||||
|
_ = c(ctx, cmd)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
func (c cmdable) SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd {
|
func (c cmdable) SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd {
|
||||||
|
|
|
@ -2317,6 +2317,28 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(lRange.Err()).NotTo(HaveOccurred())
|
Expect(lRange.Err()).NotTo(HaveOccurred())
|
||||||
Expect(lRange.Val()).To(Equal([]string{}))
|
Expect(lRange.Val()).To(Equal([]string{}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("should LMove", func() {
|
||||||
|
rPush := client.RPush(ctx, "lmove1", "ichi")
|
||||||
|
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||||
|
Expect(rPush.Val()).To(Equal(int64(1)))
|
||||||
|
|
||||||
|
rPush = client.RPush(ctx, "lmove1", "ni")
|
||||||
|
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||||
|
Expect(rPush.Val()).To(Equal(int64(2)))
|
||||||
|
|
||||||
|
rPush = client.RPush(ctx, "lmove1", "san")
|
||||||
|
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||||
|
Expect(rPush.Val()).To(Equal(int64(3)))
|
||||||
|
|
||||||
|
lMove := client.LMove(ctx, "lmove1", "lmove2", "RIGHT", "LEFT")
|
||||||
|
Expect(lMove.Err()).NotTo(HaveOccurred())
|
||||||
|
Expect(lMove.Val()).To(Equal("san"))
|
||||||
|
|
||||||
|
lRange := client.LRange(ctx, "lmove2", 0, -1)
|
||||||
|
Expect(lRange.Err()).NotTo(HaveOccurred())
|
||||||
|
Expect(lRange.Val()).To(Equal([]string{"san"}))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("sets", func() {
|
Describe("sets", func() {
|
||||||
|
|
Loading…
Reference in New Issue