aboutsummaryrefslogtreecommitdiff
path: root/pkg/commands/hkeys.go
blob: 09a5d975350608df30c3843f8d4fa72410e65ecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
}