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

Function RedisClient

pac/redis_connect.go:20–39  ·  view source on GitHub ↗

RedisClient 连接 Redis

(pwd string)

Source from the content-addressed store, hash-verified

18
19// RedisClient 连接 Redis
20func RedisClient(pwd string) (err error) {
21
22 Rdb = redis.NewClient(&redis.Options{
23 Addr: fmt.Sprintf("%s:%s", Rhost, Rport),
24 Password: pwd, // 密码认证
25 })
26
27 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
28
29 defer cancel()
30
31 pong, err := Rdb.Ping(ctx).Result()
32 if err != nil {
33 return err
34 }
35 if strings.Contains(pong, "PONG") {
36 redisVersion()
37 }
38 return nil
39}
40
41var wg sync.WaitGroup
42

Callers 2

HelpFunction · 0.85
ReddisCrackFunction · 0.85

Calls 1

redisVersionFunction · 0.85

Tested by

no test coverage detected