You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
585 B

  1. package initialize
  2. import (
  3. "gin-vue-admin/global"
  4. "github.com/go-redis/redis"
  5. "go.uber.org/zap"
  6. )
  7. func Redis() {
  8. redisCfg := global.GVA_CONFIG.Redis
  9. client := redis.NewClient(&redis.Options{
  10. Addr: redisCfg.Addr,
  11. Password: redisCfg.Password, // no password set
  12. DB: redisCfg.DB, // use default DB
  13. })
  14. pong, err := client.Ping().Result()
  15. if err != nil {
  16. global.GVA_LOG.Error("redis connect ping failed, err:", zap.Any("err", err))
  17. } else {
  18. global.GVA_LOG.Info("redis connect ping response:", zap.String("pong", pong))
  19. global.GVA_REDIS = client
  20. }
  21. }