module Sidekiq::RedisConnection
def create(options = {})
def create(options = {}) symbolized_options = deep_symbolize_keys(options) symbolized_options[:url] ||= determine_redis_provider symbolized_options[:password] = wrap(symbolized_options[:password]) if symbolized_options.key?(:password) symbolized_options[:sentinel_password] = wrap(symbolized_options[:sentinel_password]) if symbolized_options.key?(:sentinel_password) logger = symbolized_options.delete(:logger) logger&.info { "Sidekiq #{Sidekiq::VERSION} connecting to Redis with options #{scrub(symbolized_options)}" } raise "Sidekiq 7+ does not support Redis protocol 2" if symbolized_options[:protocol] == 2 safe = !!symbolized_options.delete(:cluster_safe) raise ":nodes not allowed, Sidekiq is not safe to run on Redis Cluster" if !safe && symbolized_options.key?(:nodes) size = symbolized_options.delete(:size) || 5 pool_timeout = symbolized_options.delete(:pool_timeout) || 1 pool_name = symbolized_options.delete(:pool_name) # Default timeout in redis-client is 1 second, which can be too aggressive # if the Sidekiq process is CPU-bound. With 10-15 threads and a thread quantum of 100ms, # it can be easy to get the occasional ReadTimeoutError. You can still provide # a smaller timeout explicitly: # config.redis = { url: "...", timeout: 1 } symbolized_options[:timeout] ||= 3 redis_config = Sidekiq::RedisClientAdapter.new(symbolized_options) ConnectionPool.new(timeout: pool_timeout, size: size, name: pool_name) do redis_config.new_client end end