Module: RedisClient::ConnectionMixin
- Included in:
- RubyConnection
- Defined in:
- lib/redis_client/connection_mixin.rb
Instance Method Summary collapse
- #call(command, timeout) ⇒ Object
- #call_pipelined(commands, timeouts) ⇒ Object
- #close ⇒ Object
- #initialize ⇒ Object
- #reconnect ⇒ Object
- #revalidate ⇒ Object
Instance Method Details
#call(command, timeout) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/redis_client/connection_mixin.rb', line 28 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) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/redis_client/connection_mixin.rb', line 41 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 ⇒ Object
14 15 16 17 |
# File 'lib/redis_client/connection_mixin.rb', line 14 def close @pending_reads = 0 nil end |
#initialize ⇒ Object
5 6 7 |
# File 'lib/redis_client/connection_mixin.rb', line 5 def initialize @pending_reads = 0 end |
#reconnect ⇒ Object
9 10 11 12 |
# File 'lib/redis_client/connection_mixin.rb', line 9 def reconnect close connect end |
#revalidate ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/redis_client/connection_mixin.rb', line 19 def revalidate if @pending_reads > 0 close false else connected? end end |