From 89b3019a3ab77a3e72720342fc0e5bea996fa4f2 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 12 Jul 2026 13:48:32 +0200 Subject: refactored all functions to use the command registry --- pkg/commands/hkeys.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pkg/commands/hkeys.go (limited to 'pkg/commands/hkeys.go') 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 +} -- cgit v1.2.3