Skip to content

Commit

Permalink
Add missing defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
aeroastro committed Apr 21, 2017
1 parent 71efca9 commit e94b37d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/redis/client.rb
Expand Up @@ -5,20 +5,27 @@
class Redis
class Client

# Defaults are also used for converting string keys to symbols.
DEFAULTS = {
:url => lambda { ENV["REDIS_URL"] },
:scheme => "redis",
:host => "127.0.0.1",
:port => 6379,
:path => nil,
:read_timeout => nil,
:write_timeout => nil,
:connect_timeout => nil,
:timeout => 5.0,
:password => nil,
:db => 0,
:driver => nil,
:id => nil,
:tcp_keepalive => 0,
:reconnect_attempts => 1,
:inherit_socket => false
:inherit_socket => false,
:logger => nil,
:sentinels => [],
:role => nil
}

def options
Expand Down Expand Up @@ -86,7 +93,7 @@ def initialize(options = {})

@pending_reads = 0

if options.include?(:sentinels)
if @options[:sentinels].size > 0
@connector = Connector::Sentinel.new(@options)
else
@connector = Connector.new(@options)
Expand Down Expand Up @@ -508,7 +515,7 @@ def initialize(options)
@options[:db] = DEFAULTS.fetch(:db)

@sentinels = @options.delete(:sentinels).dup
@role = @options.fetch(:role, "master").to_s
@role = (@options[:role] || "master").to_s
@master = @options[:host]
end

Expand Down

0 comments on commit e94b37d

Please sign in to comment.