lib/redic/client.rb in redic-0.0.3 vs lib/redic/client.rb in redic-0.0.4

- old
+ new

@@ -8,48 +8,29 @@ @connection = nil @semaphore = Mutex.new end def read - @connection.read.tap do |reply| - raise reply if reply.kind_of?(RuntimeError) - end + @connection.read end def write(command) @connection.write(command) end def connect - try(3) do - establish_connection unless connected? + establish_connection unless connected? - @semaphore.synchronize do - yield - end - end - end - - private - def try(times) - tries = 0 - - begin + @semaphore.synchronize do yield - rescue Exception => err - if (tries += 1) <= times - sleep 0.01 - retry - else - raise err, "%s (retries=%d)" % [err.message, tries] - end end end + private def establish_connection begin @connection = Redic::Connection.new(@uri) - rescue Exception => err + rescue StandardError => err raise err, "Can't connect to: %s" % @uri end authenticate end