Skip to content

Commit bd091de

Browse files
committed
Fix setting default timeouts.
This enables write timeout by default.
1 parent 3453fe6 commit bd091de

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lib/redis/client.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ class Client
1111
:host => "127.0.0.1",
1212
:port => 6379,
1313
:path => nil,
14-
:read_timeout => 5.0,
15-
:connect_timeout => 5.0,
16-
:write_timeout => nil,
14+
:timeout => 5.0,
1715
:password => nil,
1816
:db => 0,
1917
:driver => nil,
@@ -436,18 +434,14 @@ def _parse_options(options)
436434
end
437435

438436
if options.has_key?(:timeout)
439-
options[:read_timeout] ||= options[:timeout]
440437
options[:connect_timeout] ||= options[:timeout]
438+
options[:read_timeout] ||= options[:timeout]
439+
options[:write_timeout] ||= options[:timeout]
441440
end
442441

443-
options[:read_timeout] = options[:read_timeout].to_f
444-
options[:connect_timeout] = if options[:connect_timeout]
445-
options[:connect_timeout].to_f
446-
else
447-
options[:read_timeout]
448-
end
449-
450-
options[:write_timeout] = options[:write_timeout] ? options[:write_timeout].to_f : options[:timeout]
442+
options[:connect_timeout] = Float(options[:connect_timeout])
443+
options[:read_timeout] = Float(options[:read_timeout])
444+
options[:write_timeout] = Float(options[:write_timeout])
451445

452446
options[:db] = options[:db].to_i
453447
options[:driver] = _parse_driver(options[:driver]) || Connection.drivers.last

0 commit comments

Comments
 (0)