aboutsummaryrefslogtreecommitdiff
path: root/pkg/commands/hkeys.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/commands/hkeys.go')
-rw-r--r--pkg/commands/hkeys.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/commands/hkeys.go b/pkg/commands/hkeys.go
new file mode 100644
index 0000000..09a5d97
--- /dev/null
+++ b/pkg/commands/hkeys.go
@@ -0,0 +1,24 @@
+package commands
+
+import (
+ "errors"
+ "redisClone/pkg/core"
+)
+
+func Hkeys(args []string, getShard func(k string) *core.Shard) interface{} {
+ key := args[1]
+ s := getShard(key)
+ item, exists := s.Data[key]
+ if !exists {
+ return nil
+ }
+ hash, ok := item.Value.(map[string]string)
+ if !ok {
+ return errors.New("WRONGTYPE Operation against a key holding the wrong kind of value")
+ }
+ keys := make([]string, 0, len(hash))
+ for k := range hash {
+ keys = append(keys, k)
+ }
+ return keys
+}