mirror of https://github.com/go-redis/redis.git
Add basic BITFIELD support
This commit is contained in:
parent
4a3dbb3251
commit
bbe0a59db3
903
command.go
903
command.go
File diff suppressed because it is too large
Load Diff
11
commands.go
11
commands.go
|
@ -98,6 +98,7 @@ type Cmdable interface {
|
|||
BitOpXor(destKey string, keys ...string) *IntCmd
|
||||
BitOpNot(destKey string, key string) *IntCmd
|
||||
BitPos(key string, bit int64, pos ...int64) *IntCmd
|
||||
BitField(key string, args ...interface{}) *IntSliceCmd
|
||||
Decr(key string) *IntCmd
|
||||
DecrBy(key string, decrement int64) *IntCmd
|
||||
Get(key string) *StringCmd
|
||||
|
@ -724,6 +725,16 @@ func (c cmdable) BitPos(key string, bit int64, pos ...int64) *IntCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) BitField(key string, args ...interface{}) *IntSliceCmd {
|
||||
a := make([]interface{}, 0, 2+len(args))
|
||||
a = append(a, "bitfield")
|
||||
a = append(a, key)
|
||||
a = append(a, args...)
|
||||
cmd := NewIntSliceCmd(a...)
|
||||
c(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) Decr(key string) *IntCmd {
|
||||
cmd := NewIntCmd("decr", key)
|
||||
c(cmd)
|
||||
|
|
|
@ -968,6 +968,12 @@ var _ = Describe("Commands", func() {
|
|||
Expect(pos).To(Equal(int64(-1)))
|
||||
})
|
||||
|
||||
It("should BitField", func() {
|
||||
nn, err := client.BitField("mykey", "INCRBY", "i5", 100, 1, "GET", "u4", 0).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(nn).To(Equal([]int64{1, 0}))
|
||||
})
|
||||
|
||||
It("should Decr", func() {
|
||||
set := client.Set("key", "10", 0)
|
||||
Expect(set.Err()).NotTo(HaveOccurred())
|
||||
|
|
Loading…
Reference in New Issue