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.

22 lines
495 B

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