Class: Redis::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/pipeline.rb

Direct Known Subclasses

Multi

Defined Under Namespace

Classes: Multi

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePipeline

Returns a new instance of Pipeline.



11
12
13
14
15
# File 'lib/redis/pipeline.rb', line 11

def initialize
  @without_reconnect = false
  @shutdown = false
  @futures = []
end

Instance Attribute Details

#futuresObject (readonly)

Returns the value of attribute futures.



9
10
11
# File 'lib/redis/pipeline.rb', line 9

def futures
  @futures
end

Instance Method Details

#call(command, &block) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/redis/pipeline.rb', line 25

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) ⇒ Object



34
35
36
37
38
# File 'lib/redis/pipeline.rb', line 34

def call_pipeline(pipeline)
  @shutdown = true if pipeline.shutdown?
  @futures.concat(pipeline.futures)
  nil
end

#commandsObject



40
41
42
# File 'lib/redis/pipeline.rb', line 40

def commands
  @futures.map { |f| f._command }
end

#finish(replies) ⇒ Object



49
50
51
52
53
# File 'lib/redis/pipeline.rb', line 49

def finish(replies)
  futures.each_with_index.map do |future, i|
    future._set(replies[i])
  end
end

#shutdown?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/redis/pipeline.rb', line 21

def shutdown?
  @shutdown
end

#without_reconnect(&block) ⇒ Object



44
45
46
47
# File 'lib/redis/pipeline.rb', line 44

def without_reconnect(&block)
  @without_reconnect = true
  yield
end

#without_reconnect?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/redis/pipeline.rb', line 17

def without_reconnect?
  @without_reconnect
end