redis.go 400 B

123456789101112131415161718192021
  1. package bootstrap
  2. import (
  3. "fmt"
  4. "github.com/runningwater/gohub/pkg/config"
  5. "github.com/runningwater/gohub/pkg/redis"
  6. )
  7. // SetupRedis 初始化 Redis
  8. func SetupRedis() {
  9. // 连接 Redis
  10. redis.ConnectRedis(
  11. fmt.Sprintf("%s:%s", config.Get("redis.host"), config.Get("redis.port")),
  12. "", // redis.username 为空
  13. config.GetString("redis.password"),
  14. config.GetInt("redis.database"),
  15. )
  16. }