Module: Sidekiq::RedisConnection

Defined in:
lib/sidekiq/redis_connection.rb

Defined Under Namespace

Classes: RedisAdapter

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.adapterObject

Returns the value of attribute adapter.



65
66
67
# File 'lib/sidekiq/redis_connection.rb', line 65

def adapter
  @adapter
end

Class Method Details

.create(options = {}) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/sidekiq/redis_connection.rb', line 83

def create(options = {})
  symbolized_options = options.transform_keys(&:to_sym)

  if !symbolized_options[:url] && (u = determine_redis_provider)
    symbolized_options[:url] = u
  end

  size = if symbolized_options[:size]
    symbolized_options[:size]
  elsif Sidekiq.server?
    # Give ourselves plenty of connections.  pool is lazy
    # so we won't create them until we need them.
    Sidekiq[:concurrency] + 5
  elsif ENV["RAILS_MAX_THREADS"]
    Integer(ENV["RAILS_MAX_THREADS"])
  else
    5
  end

  verify_sizing(size, Sidekiq[:concurrency]) if Sidekiq.server?

  pool_timeout = symbolized_options[:pool_timeout] || 1
  log_info(symbolized_options)

  redis_config = adapter.new(symbolized_options)
  ConnectionPool.new(timeout: pool_timeout, size: size) do
    redis_config.new_client
  end
end