module RedisClient::ConnectionMixin
Public Class Methods
new()
click to toggle source
# File lib/redis_client/connection_mixin.rb, line 4 def initialize @pending_reads = 0 end
Public Instance Methods
call(command, timeout)
click to toggle source
# File lib/redis_client/connection_mixin.rb, line 27 def call(command, timeout) @pending_reads += 1 write(command) result = read(timeout) @pending_reads -= 1 if result.is_a?(Error) result._set_command(command) raise result else result end end
call_pipelined(commands, timeouts)
click to toggle source
# File lib/redis_client/connection_mixin.rb, line 40 def call_pipelined(commands, timeouts) exception = nil size = commands.size results = Array.new(commands.size) @pending_reads += size write_multi(commands) size.times do |index| timeout = timeouts && timeouts[index] result = read(timeout) @pending_reads -= 1 if result.is_a?(Error) result._set_command(commands[index]) exception ||= result end results[index] = result end if exception raise exception else results end end
close()
click to toggle source
# File lib/redis_client/connection_mixin.rb, line 13 def close @pending_reads = 0 nil end
reconnect()
click to toggle source
# File lib/redis_client/connection_mixin.rb, line 8 def reconnect close connect end
revalidate()
click to toggle source
# File lib/redis_client/connection_mixin.rb, line 18 def revalidate if @pending_reads > 0 close false else connected? end end