From 7b0fe4aef97c6a5f73a03146b669a415f396799c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 29 Apr 2022 22:43:07 +0200 Subject: Fix opening and closing Redis connections instead of using a pool (#18171) * Fix opening and closing Redis connections instead of using a pool * Fix Redis connections not being returned to the pool in CLI commands --- app/lib/redis_configuration.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/lib') diff --git a/app/lib/redis_configuration.rb b/app/lib/redis_configuration.rb index fc8cf2f80f8..e14d6c8b670 100644 --- a/app/lib/redis_configuration.rb +++ b/app/lib/redis_configuration.rb @@ -2,12 +2,17 @@ class RedisConfiguration class << self + def establish_pool(new_pool_size) + @pool&.shutdown(&:close) + @pool = ConnectionPool.new(size: new_pool_size) { new.connection } + end + def with pool.with { |redis| yield redis } end def pool - @pool ||= ConnectionPool.new(size: pool_size) { new.connection } + @pool ||= establish_pool(pool_size) end def pool_size -- cgit v1.2.3