From 65932a4b9b1ece65787ee1eb225996e87ff202b5 Mon Sep 17 00:00:00 2001 From: Jake Gregg Date: Tue, 29 Jan 2019 10:39:58 -0800 Subject: [PATCH] :sparkles: Add GETKEYSINSLOT api call for clustered redis --- cluster_test.go | 6 ++++++ commands.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/cluster_test.go b/cluster_test.go index d39ebd0..51633e9 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -637,6 +637,12 @@ var _ = Describe("ClusterClient", func() { Expect(hashSlot).To(Equal(int64(hashtag.Slot("somekey")))) }) + It("should CLUSTER GETKEYSINSLOT", func() { + keys, err := client.ClusterGetKeysInSlot(hashtag.Slot("somekey"), 1).Result() + Expect(err).NotTo(HaveOccurred()) + Expect(len(keys)).To(Equal(0)) + }) + It("should CLUSTER COUNT-FAILURE-REPORTS", func() { n, err := client.ClusterCountFailureReports(cluster.nodeIds[0]).Result() Expect(err).NotTo(HaveOccurred()) diff --git a/commands.go b/commands.go index f5e34d4..6433595 100644 --- a/commands.go +++ b/commands.go @@ -270,6 +270,7 @@ type Cmdable interface { ClusterResetHard() *StatusCmd ClusterInfo() *StringCmd ClusterKeySlot(key string) *IntCmd + ClusterGetKeysInSlot(slot int, count int) *StringSliceCmd ClusterCountFailureReports(nodeID string) *IntCmd ClusterCountKeysInSlot(slot int) *IntCmd ClusterDelSlots(slots ...int) *StatusCmd @@ -2402,6 +2403,12 @@ func (c *cmdable) ClusterKeySlot(key string) *IntCmd { return cmd } +func (c *cmdable) ClusterGetKeysInSlot(slot int, count int) *StringSliceCmd { + cmd := NewStringSliceCmd("cluster", "getkeysinslot", slot, count) + c.process(cmd) + return cmd +} + func (c *cmdable) ClusterCountFailureReports(nodeID string) *IntCmd { cmd := NewIntCmd("cluster", "count-failure-reports", nodeID) c.process(cmd)