MCPcopy
hub / github.com/gourouting/singo / Redis

Function Redis

cache/cache.go:16–32  ·  view source on GitHub ↗

Redis initializes the Redis connection.

()

Source from the content-addressed store, hash-verified

14
15// Redis initializes the Redis connection.
16func Redis() {
17 db, _ := strconv.ParseUint(os.Getenv("REDIS_DB"), 10, 64)
18 client := redis.NewClient(&redis.Options{
19 Addr: os.Getenv("REDIS_ADDR"),
20 Password: os.Getenv("REDIS_PW"),
21 DB: int(db),
22 MaxRetries: 1,
23 })
24
25 _, err := client.Ping(context.Background()).Result()
26
27 if err != nil {
28 util.Log().Panic("failed to connect to Redis: %v", err)
29 }
30
31 RedisClient = client
32}

Callers 2

InitFunction · 0.92
confInitFunction · 0.92

Calls 2

LogFunction · 0.92
PanicMethod · 0.80

Tested by

no test coverage detected