mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Add support for COMMAND GETKEYS & COMMAND GETKEYSANDFLAGS (#2500)
* feat: Adding support for CommandsGetKeysAndFlags & CommandGetKeys Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6790337e5d
commit
984bc2810d
@ -132,6 +132,43 @@ var _ = Describe("Commands", func() {
|
||||
}, "30s").Should(Equal("Background saving started"))
|
||||
})
|
||||
|
||||
It("Should CommandGetKeys", func() {
|
||||
keys, err := client.CommandGetKeys(ctx, "MSET", "a", "b", "c", "d", "e", "f").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(keys).To(Equal([]string{"a", "c", "e"}))
|
||||
|
||||
keys, err = client.CommandGetKeys(ctx, "EVAL", "not consulted", "3", "key1", "key2", "key3", "arg1", "arg2", "arg3", "argN").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(keys).To(Equal([]string{"key1", "key2", "key3"}))
|
||||
|
||||
keys, err = client.CommandGetKeys(ctx, "SORT", "mylist", "ALPHA", "STORE", "outlist").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(keys).To(Equal([]string{"mylist", "outlist"}))
|
||||
|
||||
_, err = client.CommandGetKeys(ctx, "FAKECOMMAND", "arg1", "arg2").Result()
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError("ERR Invalid command specified"))
|
||||
})
|
||||
|
||||
It("should CommandGetKeysAndFlags", func() {
|
||||
keysAndFlags, err := client.CommandGetKeysAndFlags(ctx, "LMOVE", "mylist1", "mylist2", "left", "left").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(keysAndFlags).To(Equal([]redis.KeyFlags{
|
||||
{
|
||||
Key: "mylist1",
|
||||
Flags: []string{"RW", "access", "delete"},
|
||||
},
|
||||
{
|
||||
Key: "mylist2",
|
||||
Flags: []string{"RW", "insert"},
|
||||
},
|
||||
}))
|
||||
|
||||
_, err = client.CommandGetKeysAndFlags(ctx, "FAKECOMMAND", "arg1", "arg2").Result()
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError("ERR Invalid command specified"))
|
||||
})
|
||||
|
||||
It("should ClientKill", func() {
|
||||
r := client.ClientKill(ctx, "1.1.1.1:1111")
|
||||
Expect(r.Err()).To(MatchError("ERR No such client"))
|
||||
|
Reference in New Issue
Block a user