mirror of https://github.com/go-redis/redis.git
parent
31495ac570
commit
8f0fbd2fe8
|
@ -179,6 +179,7 @@ type Cmdable interface {
|
|||
LInsertAfter(ctx context.Context, key string, pivot, value interface{}) *IntCmd
|
||||
LLen(ctx context.Context, key string) *IntCmd
|
||||
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
|
||||
LPosCount(ctx context.Context, key string, value string, count int64, args LPosArgs) *IntSliceCmd
|
||||
LPush(ctx context.Context, key string, values ...interface{}) *IntCmd
|
||||
|
@ -1314,6 +1315,12 @@ func (c cmdable) LPop(ctx context.Context, key string) *StringCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) LPopCount(ctx context.Context, key string, count int) *StringSliceCmd {
|
||||
cmd := NewStringSliceCmd(ctx, "lpop", key, count)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
type LPosArgs struct {
|
||||
Rank, MaxLen int64
|
||||
}
|
||||
|
|
|
@ -2050,6 +2050,25 @@ var _ = Describe("Commands", func() {
|
|||
Expect(lRange.Val()).To(Equal([]string{"two", "three"}))
|
||||
})
|
||||
|
||||
It("should LPopCount", func() {
|
||||
rPush := client.RPush(ctx, "list", "one")
|
||||
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||
rPush = client.RPush(ctx, "list", "two")
|
||||
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||
rPush = client.RPush(ctx, "list", "three")
|
||||
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||
rPush = client.RPush(ctx, "list", "four")
|
||||
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||
|
||||
lPopCount := client.LPopCount(ctx, "list", 2)
|
||||
Expect(lPopCount.Err()).NotTo(HaveOccurred())
|
||||
Expect(lPopCount.Val()).To(Equal([]string{"one", "two"}))
|
||||
|
||||
lRange := client.LRange(ctx, "list", 0, -1)
|
||||
Expect(lRange.Err()).NotTo(HaveOccurred())
|
||||
Expect(lRange.Val()).To(Equal([]string{"three", "four"}))
|
||||
})
|
||||
|
||||
It("should LPos", func() {
|
||||
rPush := client.RPush(ctx, "list", "a")
|
||||
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||
|
|
Loading…
Reference in New Issue