Class: Redis::Connection::Hiredis

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/connection/hiredis.rb

Instance Method Summary collapse

Constructor Details

#initializeHiredis

Returns a new instance of Hiredis.



8
9
10
# File 'lib/redis/connection/hiredis.rb', line 8

def initialize
  @connection = ::Hiredis::Connection.new
end

Instance Method Details

#connect(host, port, timeout) ⇒ Object



20
21
22
23
24
# File 'lib/redis/connection/hiredis.rb', line 20

def connect(host, port, timeout)
  @connection.connect(host, port, timeout)
rescue Errno::ETIMEDOUT
  raise Timeout::Error
end

#connect_unix(path, timeout) ⇒ Object



26
27
28
29
30
# File 'lib/redis/connection/hiredis.rb', line 26

def connect_unix(path, timeout)
  @connection.connect_unix(path, timeout)
rescue Errno::ETIMEDOUT
  raise Timeout::Error
end

#connected?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/redis/connection/hiredis.rb', line 12

def connected?
  @connection.connected?
end

#disconnectObject



32
33
34
# File 'lib/redis/connection/hiredis.rb', line 32

def disconnect
  @connection.disconnect
end

#readObject



40
41
42
43
44
# File 'lib/redis/connection/hiredis.rb', line 40

def read
  @connection.read
rescue RuntimeError => err
  raise ::Redis::ProtocolError.new(err.message)
end

#timeout=(usecs) ⇒ Object



16
17
18
# File 'lib/redis/connection/hiredis.rb', line 16

def timeout=(usecs)
  @connection.timeout = usecs
end

#write(command) ⇒ Object



36
37
38
# File 'lib/redis/connection/hiredis.rb', line 36

def write(command)
  @connection.write(command)
end