Class: Sidekiq::RedisConnection::RedisAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/redis_connection.rb

Constant Summary collapse

BaseError =
Redis::BaseError
CommandError =
Redis::CommandError

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RedisAdapter

Returns a new instance of RedisAdapter.



13
14
15
16
# File 'lib/sidekiq/redis_connection.rb', line 13

def initialize(options)
  warn("Usage of the 'redis' gem within Sidekiq itself is deprecated, Sidekiq 7.0 will only use the new, simpler 'redis-client' gem", caller) if ENV["SIDEKIQ_REDIS_CLIENT"] == "1"
  @options = options
end

Instance Method Details

#new_clientObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sidekiq/redis_connection.rb', line 18

def new_client
  namespace = @options[:namespace]

  client = Redis.new client_opts(@options)
  if namespace
    begin
      require "redis/namespace"
      Redis::Namespace.new(namespace, redis: client)
    rescue LoadError
      Sidekiq.logger.error("Your Redis configuration uses the namespace '#{namespace}' but the redis-namespace gem is not included in the Gemfile." \
                           "Add the gem to your Gemfile to continue using a namespace. Otherwise, remove the namespace parameter.")
      exit(-127)
    end
  else
    client
  end
end