lib/ldclient-rb/impl/integrations/redis_impl.rb in launchdarkly-server-sdk-5.7.4 vs lib/ldclient-rb/impl/integrations/redis_impl.rb in launchdarkly-server-sdk-5.8.0

- old
+ new

@@ -31,10 +31,12 @@ end max_connections = opts[:max_connections] || 16 @pool = opts[:pool] || ConnectionPool.new(size: max_connections) do ::Redis.new(@redis_opts) end + # shutdown pool on close unless the client passed a custom pool and specified not to shutdown + @pool_shutdown_on_close = (!opts[:pool] || opts.fetch(:pool_shutdown_on_close, true)) @prefix = opts[:prefix] || LaunchDarkly::Integrations::Redis::default_prefix @logger = opts[:logger] || Config.default_logger @test_hook = opts[:test_hook] # used for unit tests, deliberately undocumented @stopped = Concurrent::AtomicBoolean.new(false) @@ -116,9 +118,10 @@ with_connection { |redis| redis.exists(inited_key) } end def stop if @stopped.make_true + return unless @pool_shutdown_on_close @pool.shutdown { |redis| redis.close } end end private