Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cache/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@ type redisClusterClient struct {

// NewRedisClient create a client for standalone redis or redis cluster.
func NewRedisClient() RedisClient {
addrs := strings.Split(os.Getenv("REDIS_URL"), ",")
redisURL := os.Getenv("REDIS_URL")
env := os.Getenv("ENV")
cluster := env != "local" && env != ""
poolSize, err := strconv.Atoi(os.Getenv("REDIS_POOL_SIZE"))
if err != nil {
poolSize = 100
}

// Fallback to localhost:6397 and non-cluster client if redis env is not set.
if len(addrs) == 0 {
addrs = []string{"localhost:6397"}
// Fallback to localhost:6379 and non-cluster client if redis env is not set.
var addrs []string
if redisURL == "" {
addrs = []string{"localhost:6379"}
cluster = false
} else {
addrs = strings.Split(redisURL, ",")
}

var r RedisClient
Expand Down