diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb index d1aa25b2e..1566098c9 100644 --- a/config/initializers/redis.rb +++ b/config/initializers/redis.rb @@ -4,7 +4,3 @@ redis = Rails.env.test? ? MockRedis.new : Redis.new(Redis::Config.app) # Add here as you use it for more features # Used for Round Robin, Conversation Emails & Online Presence $alfred = Redis::Namespace.new('alfred', redis: redis, warning: true) - -# https://github.com/mperham/sidekiq/issues/4591 -# TODO once sidekiq remove we can remove this -Redis.exists_returns_integer = false diff --git a/lib/redis/config.rb b/lib/redis/config.rb index 888ae89c3..35ea3e617 100644 --- a/lib/redis/config.rb +++ b/lib/redis/config.rb @@ -18,7 +18,9 @@ module Redis::Config def base_config { url: ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379'), - password: ENV.fetch('REDIS_PASSWORD', nil).presence + password: ENV.fetch('REDIS_PASSWORD', nil).presence, + reconnect_attempts: 2, + network_timeout: 5 } end diff --git a/spec/lib/redis/config_spec.rb b/spec/lib/redis/config_spec.rb index fa4f4c74c..2b919696f 100644 --- a/spec/lib/redis/config_spec.rb +++ b/spec/lib/redis/config_spec.rb @@ -16,14 +16,14 @@ describe ::Redis::Config do it 'checks for app redis config' do app_config = described_class.app - expect(app_config.keys).to match_array([:url, :password]) + expect(app_config.keys).to match_array([:url, :password, :network_timeout, :reconnect_attempts]) expect(app_config[:url]).to eq(redis_url) expect(app_config[:password]).to eq(redis_pasword) end it 'checks for sidekiq redis config' do sidekiq_config = described_class.sidekiq - expect(sidekiq_config.keys).to match_array([:url, :password, :size]) + expect(sidekiq_config.keys).to match_array([:url, :password, :size, :network_timeout, :reconnect_attempts]) expect(sidekiq_config[:url]).to eq redis_url expect(sidekiq_config[:password]).to eq redis_pasword expect(sidekiq_config[:size]).to eq described_class::SIDEKIQ_SIZE @@ -54,13 +54,13 @@ describe ::Redis::Config do end it 'checks for app redis config' do - expect(described_class.app.keys).to match_array([:url, :password, :sentinels]) + expect(described_class.app.keys).to match_array([:url, :password, :sentinels, :network_timeout, :reconnect_attempts]) expect(described_class.app[:url]).to eq("redis://#{redis_master_name}") expect(described_class.app[:sentinels]).to match_array(expected_sentinels) end it 'checks for sidekiq redis config' do - expect(described_class.sidekiq.keys).to match_array([:url, :password, :sentinels, :size]) + expect(described_class.sidekiq.keys).to match_array([:url, :password, :sentinels, :size, :network_timeout, :reconnect_attempts]) expect(described_class.sidekiq[:size]).to eq described_class::SIDEKIQ_SIZE end end