12345678910111213141516171819202122232425 |
- package init_serve
- import (
- "context"
- "github.com/go-redis/redis/v8"
- "hongze/hongze_yb/global"
- )
- func Redis() {
- redisConf := global.CONFIG.Redis
- client := redis.NewClient(&redis.Options{
- Addr: redisConf.Address,
- Password: redisConf.Password,
- DB: redisConf.Db,
-
- })
- _, err := client.Ping(context.TODO()).Result()
- if err != nil {
- global.LOG.Error("redis 链接失败:", err)
- panic("redis 链接失败:" + err.Error())
- }
-
- global.Redis = client
- }
|