Skip to content

Commit

Permalink
Merge pull request #72 from brave/increase_redis_pool_size
Browse files Browse the repository at this point in the history
Increase REDIS connection pool size
  • Loading branch information
hspencer77 authored Jun 14, 2021
2 parents 1a8d444 + 4a5cfe5 commit 19ac42d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cache/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cache
import (
"context"
"os"
"strconv"
"strings"
"time"

Expand All @@ -29,6 +30,10 @@ type redisClusterClient struct {
func NewRedisClient() RedisClient {
addrs := strings.Split(os.Getenv("REDIS_URL"), ",")
cluster := os.Getenv("ENV") != "local"
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 {
Expand All @@ -45,7 +50,8 @@ func NewRedisClient() RedisClient {
r = &redisSimpleClient{client}
} else {
client := redis.NewClusterClient(&redis.ClusterOptions{
Addrs: addrs,
Addrs: addrs,
PoolSize: poolSize,
})
r = &redisClusterClient{client}
}
Expand Down

0 comments on commit 19ac42d

Please sign in to comment.