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