diff options
Diffstat (limited to 'pkg/commands/type.go')
| -rw-r--r-- | pkg/commands/type.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/commands/type.go b/pkg/commands/type.go new file mode 100644 index 0000000..2a7ef95 --- /dev/null +++ b/pkg/commands/type.go @@ -0,0 +1,24 @@ +package commands + +import ( + "redisClone/pkg/core" +) + +func Type(args []string, getShard func(k string) *core.Shard) interface{} { + key := args[1] + s := getShard(key) + item, exists := s.Data[key] + if !exists { + return core.SimpleString("none") + } + switch item.Value.(type) { + case string: + return core.SimpleString("string") + case []string: + return core.SimpleString("list") + case map[string]string: + return core.SimpleString("hash") + default: + return core.SimpleString("unknown") + } +} |
