Compare commits

..

No commits in common. "536b9eb29add66fabf6a285b4f17270a3b2f502e" and "fdc3674ff5cc236f3c5501f29eedd823f9f93465" have entirely different histories.

1 changed files with 5 additions and 7 deletions

View File

@ -464,8 +464,7 @@ func GetRedisSetUnion(key1 string, key2 string) []string {
type RedisInfo struct {
Key string
Value string
Type string
Expire int // 过期时间, 单位: 秒
Expire time.Duration
}
// 获取所有的key和value,及其对应的过期时间
@ -479,7 +478,7 @@ func GetAllRedisInfo() ([]RedisInfo, error) {
var redisInfos []RedisInfo
for _, key := range keys {
//先查看key类型再根据类型获取value
key_type, val, err := getKeyTypeAndData(key)
val, err := getKeyTypeAndData(key)
if err != nil {
fmt.Println("Error getting key: %v", err)
return nil, err
@ -492,15 +491,14 @@ func GetAllRedisInfo() ([]RedisInfo, error) {
redisInfo := RedisInfo{
Key: key,
Value: val,
Type: key_type,
Expire: int(expire.Seconds()),
Expire: expire,
}
redisInfos = append(redisInfos, redisInfo)
}
return redisInfos, nil
}
func getKeyTypeAndData(key string) (string, string, error) {
func getKeyTypeAndData(key string) (string, error) {
ctx := context.Background()
key_type := RedisClient.Type(ctx, key).Val()
var val interface{}
@ -521,5 +519,5 @@ func getKeyTypeAndData(key string) (string, string, error) {
default:
val = "unknown type"
}
return key_type, fmt.Sprintf("%v", val), err
return fmt.Sprintf("%v", val), err
}