Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase REDIS connection pool size #72

Merged
merged 1 commit into from
Jun 14, 2021
Merged
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
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