MCPcopy Create free account
hub / github.com/Hel10-Web/Databasetools / handle_export

Function handle_export

pac/redis_export.go:53–140  ·  view source on GitHub ↗

Redis 导出

()

Source from the content-addressed store, hash-verified

51
52// Redis 导出
53func handle_export() {
54 redisInfo := RedisInfo{}
55 var cursor uint64
56 keys, cursor, err := Rdb.Scan(ctx, cursor, "*", 100).Result()
57 if err != nil {
58 Err(err)
59 return
60 }
61
62 for _, key := range keys {
63 sType, err := Rdb.Type(ctx, key).Result()
64 if err != nil {
65 Err(err)
66 return
67 }
68
69 switch sType {
70 case "string":
71 val, _ := Rdb.Get(ctx, key).Result()
72 strInfo := String{
73 Key: key,
74 Val: val,
75 }
76 redisInfo.String = append(redisInfo.String, strInfo)
77
78 case "list":
79 val, _ := Rdb.LPop(ctx, key).Result()
80 listInfo := List{
81 Key: key,
82 Data: val,
83 }
84
85 redisInfo.List = append(redisInfo.List, listInfo)
86
87 case "hash":
88 val, _ := Rdb.HGetAll(ctx, key).Result()
89 hashInfo := Hash{
90 Key: key,
91 }
92
93 for k, v := range val {
94 data := HashData{
95 Field: k,
96 Val: v,
97 }
98 hashInfo.Data = append(hashInfo.Data, data)
99 }
100 redisInfo.Hash = append(redisInfo.Hash, hashInfo)
101
102 case "set":
103 val, _ := Rdb.SMembers(ctx, key).Result()
104 setInfo := Set{
105 Key: key,
106 Data: val,
107 }
108 redisInfo.Set = append(redisInfo.Set, setInfo)
109
110 case "zset":

Callers 2

RedisSlaveFunction · 0.85
HelpFunction · 0.85

Calls 3

ErrFunction · 0.85
InfoFunction · 0.85
SuccessFunction · 0.85

Tested by

no test coverage detected