Sha256: 8d84e3b14fdec222101c5c818b299a36552f118bc43e76a599b70ba8fa0a0cd2
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
require 'redis/connection/registry' require 'redis/errors' require 'oxblood' class Redis module Connection class Oxblood def self.connect(config) unless config[:path] config = config.dup config.delete(:path) end connection = ::Oxblood::Connection.open(config) new(connection) end def initialize(connection) @connection = connection end def connected? @connection && @connection.connected? end def timeout=(timeout) @connection.timeout = timeout > 0 ? timeout : nil end def disconnect @connection.close end def write(command) @connection.send_command(*command) end 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::Connection::TimeoutError => e raise Redis::TimeoutError.new(e.message) end if defined?(Encoding::default_external) def encode(string) string.force_encoding(Encoding::default_external) end else def encode(string) string end end end end end Redis::Connection.drivers << Redis::Connection::Oxblood
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oxblood-0.1.0.dev6 | lib/redis/connection/oxblood.rb |
oxblood-0.1.0.dev5 | lib/redis/connection/oxblood.rb |
oxblood-0.1.0.dev4 | lib/redis/connection/oxblood.rb |