diff options
Diffstat (limited to 'pkg/commands/hvalues.go')
| -rw-r--r-- | pkg/commands/hvalues.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/commands/hvalues.go b/pkg/commands/hvalues.go new file mode 100644 index 0000000..1034fbd --- /dev/null +++ b/pkg/commands/hvalues.go @@ -0,0 +1,24 @@ +package commands + +import ( + "errors" + "redisClone/pkg/core" +) + +func Hvalues(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") + } + values := make([]string, 0, len(hash)) + for _, v := range hash { + values = append(values, v) + } + return values +} |
