forked from mirror/redis
Merge pull request #1742 from nigelis/feature/add_smismember_command
Add command SMISMEMBER
This commit is contained in:
commit
b45fc83959
12
commands.go
12
commands.go
|
@ -200,6 +200,7 @@ type Cmdable interface {
|
||||||
SInter(ctx context.Context, keys ...string) *StringSliceCmd
|
SInter(ctx context.Context, keys ...string) *StringSliceCmd
|
||||||
SInterStore(ctx context.Context, destination string, keys ...string) *IntCmd
|
SInterStore(ctx context.Context, destination string, keys ...string) *IntCmd
|
||||||
SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd
|
SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd
|
||||||
|
SMIsMember(ctx context.Context, key string, members ...interface{}) *BoolSliceCmd
|
||||||
SMembers(ctx context.Context, key string) *StringSliceCmd
|
SMembers(ctx context.Context, key string) *StringSliceCmd
|
||||||
SMembersMap(ctx context.Context, key string) *StringStructMapCmd
|
SMembersMap(ctx context.Context, key string) *StringStructMapCmd
|
||||||
SMove(ctx context.Context, source, destination string, member interface{}) *BoolCmd
|
SMove(ctx context.Context, source, destination string, member interface{}) *BoolCmd
|
||||||
|
@ -1508,6 +1509,17 @@ func (c cmdable) SIsMember(ctx context.Context, key string, member interface{})
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redis `SMISMEMBER key member [member ...]` command.
|
||||||
|
func (c cmdable) SMIsMember(ctx context.Context, key string, members ...interface{}) *BoolSliceCmd {
|
||||||
|
args := make([]interface{}, 2, 2+len(members))
|
||||||
|
args[0] = "smismember"
|
||||||
|
args[1] = key
|
||||||
|
args = appendArgs(args, members)
|
||||||
|
cmd := NewBoolSliceCmd(ctx, args...)
|
||||||
|
_ = c(ctx, cmd)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
// Redis `SMEMBERS key` command output as a slice.
|
// Redis `SMEMBERS key` command output as a slice.
|
||||||
func (c cmdable) SMembers(ctx context.Context, key string) *StringSliceCmd {
|
func (c cmdable) SMembers(ctx context.Context, key string) *StringSliceCmd {
|
||||||
cmd := NewStringSliceCmd(ctx, "smembers", key)
|
cmd := NewStringSliceCmd(ctx, "smembers", key)
|
||||||
|
|
|
@ -2486,6 +2486,15 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(sIsMember.Val()).To(Equal(false))
|
Expect(sIsMember.Val()).To(Equal(false))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("should SMIsMember", func() {
|
||||||
|
sAdd := client.SAdd(ctx, "set", "one")
|
||||||
|
Expect(sAdd.Err()).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
sMIsMember := client.SMIsMember(ctx, "set", "one", "two")
|
||||||
|
Expect(sMIsMember.Err()).NotTo(HaveOccurred())
|
||||||
|
Expect(sMIsMember.Val()).To(Equal([]bool{true, false}))
|
||||||
|
})
|
||||||
|
|
||||||
It("should SMembers", func() {
|
It("should SMembers", func() {
|
||||||
sAdd := client.SAdd(ctx, "set", "Hello")
|
sAdd := client.SAdd(ctx, "set", "Hello")
|
||||||
Expect(sAdd.Err()).NotTo(HaveOccurred())
|
Expect(sAdd.Err()).NotTo(HaveOccurred())
|
||||||
|
|
Loading…
Reference in New Issue