aboutsummaryrefslogtreecommitdiff
path: root/pkg/commands/type.go
blob: 2a7ef95fd527d69a3e39d41e5ea4cc5aaefeb50d (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 (
	"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")
	}
}