diff options
Diffstat (limited to 'pkg/commands/hget.go')
| -rw-r--r-- | pkg/commands/hget.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/commands/hget.go b/pkg/commands/hget.go new file mode 100644 index 0000000..7d16808 --- /dev/null +++ b/pkg/commands/hget.go @@ -0,0 +1,25 @@ +package commands + +import ( + "errors" + "redisClone/pkg/core" +) + +func Hget(args []string, getShard func(k string) *core.Shard) interface{} { + key := args[1] + field := args[2] + 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") + } + val, found := hash[field] + if !found { + return nil + } + return val +} |
