liuhaijun e94826ce29 add server
Change-Id: I0760f17f6a01c0121b59fcbfafc666032dbc30af
2024-09-19 09:44:15 +00:00

24 lines
483 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package data
import (
"context"
c "git.inspur.com/sbg-jszt/cfn/cfn-schedule/config"
"github.com/go-redis/redis/v8"
)
var Rdb *redis.Client
func initRedis() {
Rdb = redis.NewClient(&redis.Options{
Addr: c.Config.Redis.Host + ":" + c.Config.Redis.Port,
Password: c.Config.Redis.Password,
DB: c.Config.Redis.Database,
})
var ctx = context.Background()
_, err := Rdb.Ping(ctx).Result()
if err != nil {
panic("Redis connection failed" + err.Error())
}
}