class Redis::Client

def establish_connection

def establish_connection
  # Need timeout in usecs, like socket timeout.
  timeout = Integer(@timeout * 1_000_000)
  if @path
    connection.connect_unix(@path, timeout)
  else
    connection.connect(@host, @port, timeout)
  end
  # If the timeout is set we set the low level socket options in order
  # to make sure a blocking read will return after the specified number
  # of seconds. This hack is from memcached ruby client.
  self.timeout = @timeout
rescue Errno::ECONNREFUSED
  raise Errno::ECONNREFUSED, "Unable to connect to Redis on #{location}"
end