class Redis::Pipeline
Constants
- REDIS_INTERNAL_PATH
- STDLIB_PATH
Redis
use MonitorMixin#synchronize and this class use DelegateClass which we want to filter out. Both are in the stdlib so we can simply filter the entire stdlib out.
Attributes
client[R]
db[RW]
futures[R]
Public Class Methods
new(client)
click to toggle source
# File lib/redis/pipeline.rb, line 73 def initialize(client) @client = client.is_a?(Pipeline) ? client.client : client @with_reconnect = true @shutdown = false @futures = [] end
Public Instance Methods
call(command, timeout: nil, &block)
click to toggle source
# File lib/redis/pipeline.rb, line 100 def call(command, timeout: nil, &block) # A pipeline that contains a shutdown should not raise ECONNRESET when # the connection is gone. @shutdown = true if command.first == :shutdown future = Future.new(command, block, timeout) @futures << future future end
call_pipeline(pipeline)
click to toggle source
# File lib/redis/pipeline.rb, line 113 def call_pipeline(pipeline) @shutdown = true if pipeline.shutdown? @futures.concat(pipeline.futures) @db = pipeline.db nil end
call_with_timeout(command, timeout, &block)
click to toggle source
# File lib/redis/pipeline.rb, line 109 def call_with_timeout(command, timeout, &block) call(command, timeout: timeout, &block) end
commands()
click to toggle source
# File lib/redis/pipeline.rb, line 120 def commands @futures.map(&:_command) end
empty?()
click to toggle source
# File lib/redis/pipeline.rb, line 96 def empty? @futures.empty? end
finish(replies, &blk)
click to toggle source
# File lib/redis/pipeline.rb, line 137 def finish(replies, &blk) if blk futures.each_with_index.map do |future, i| future._set(blk.call(replies[i])) end else futures.each_with_index.map do |future, i| future._set(replies[i]) end end end
shutdown?()
click to toggle source
# File lib/redis/pipeline.rb, line 92 def shutdown? @shutdown end
timeout()
click to toggle source
# File lib/redis/pipeline.rb, line 80 def timeout client.timeout end
timeouts()
click to toggle source
# File lib/redis/pipeline.rb, line 124 def timeouts @futures.map(&:timeout) end
with_reconnect(val = true) { || ... }
click to toggle source
# File lib/redis/pipeline.rb, line 128 def with_reconnect(val = true) @with_reconnect = false unless val yield end
with_reconnect?()
click to toggle source
# File lib/redis/pipeline.rb, line 84 def with_reconnect? @with_reconnect end
without_reconnect(&blk)
click to toggle source
# File lib/redis/pipeline.rb, line 133 def without_reconnect(&blk) with_reconnect(false, &blk) end
without_reconnect?()
click to toggle source
# File lib/redis/pipeline.rb, line 88 def without_reconnect? !@with_reconnect end