class Redis::Connection::Oxblood
Public Class Methods
connect(config)
click to toggle source
# File lib/redis/connection/oxblood.rb, line 8 def self.connect(config) unless config[:path] config = config.dup config.delete(:path) end connection = ::Oxblood::Connection.new(config) new(connection) end
new(connection)
click to toggle source
# File lib/redis/connection/oxblood.rb, line 18 def initialize(connection) @connection = connection end
Public Instance Methods
connected?()
click to toggle source
# File lib/redis/connection/oxblood.rb, line 22 def connected? @connection.socket && @connection.socket.connected? end
disconnect()
click to toggle source
# File lib/redis/connection/oxblood.rb, line 30 def disconnect @connection.socket.close end
encode(string)
click to toggle source
# File lib/redis/connection/oxblood.rb, line 50 def encode(string) string.force_encoding(Encoding::default_external) end
read()
click to toggle source
# File lib/redis/connection/oxblood.rb, line 38 def read reply = @connection.read_response reply = encode(reply) if reply.is_a?(String) reply = CommandError.new(reply.message) if reply.is_a?(::Oxblood::Protocol::RError) reply rescue ::Oxblood::Protocol::ParserError => e raise Redis::ProtocolError.new(e.message) rescue ::Oxblood::RSocket::TimeoutError => e raise Redis::TimeoutError.new(e.message) end
timeout=(timeout)
click to toggle source
# File lib/redis/connection/oxblood.rb, line 26 def timeout=(timeout) @connection.socket.timeout = timeout > 0 ? timeout : nil end
write(command)
click to toggle source
# File lib/redis/connection/oxblood.rb, line 34 def write(command) @connection.send_command(*command) end