class Redis::Pipeline

Attributes

db[RW]
futures[R]

Public Class Methods

new() click to toggle source
# File lib/redis/pipeline.rb, line 13
def initialize
  @with_reconnect = true
  @shutdown = false
  @futures = []
end

Public Instance Methods

call(command, &block) click to toggle source
# File lib/redis/pipeline.rb, line 31
def call(command, &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)
  @futures << future
  future
end
call_pipeline(pipeline) click to toggle source
# File lib/redis/pipeline.rb, line 40
def call_pipeline(pipeline)
  @shutdown = true if pipeline.shutdown?
  @futures.concat(pipeline.futures)
  @db = pipeline.db
  nil
end
commands() click to toggle source
# File lib/redis/pipeline.rb, line 47
def commands
  @futures.map { |f| f._command }
end
finish(replies, &blk) click to toggle source
# File lib/redis/pipeline.rb, line 60
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 27
def shutdown?
  @shutdown
end
with_reconnect(val=true) { || ... } click to toggle source
# File lib/redis/pipeline.rb, line 51
def with_reconnect(val=true)
  @with_reconnect = false unless val
  yield
end
with_reconnect?() click to toggle source
# File lib/redis/pipeline.rb, line 19
def with_reconnect?
  @with_reconnect
end
without_reconnect(&blk) click to toggle source
# File lib/redis/pipeline.rb, line 56
def without_reconnect(&blk)
  with_reconnect(false, &blk)
end
without_reconnect?() click to toggle source
# File lib/redis/pipeline.rb, line 23
def without_reconnect?
  !@with_reconnect
end