Class: Redis::Pipeline
- Inherits:
-
Object
- Object
- Redis::Pipeline
- Defined in:
- lib/redis/pipeline.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Multi
Instance Attribute Summary collapse
-
#futures ⇒ Object
readonly
Returns the value of attribute futures.
Instance Method Summary collapse
- #call(command, &block) ⇒ Object
- #call_pipeline(pipeline) ⇒ Object
- #commands ⇒ Object
- #finish(replies) ⇒ Object
-
#initialize ⇒ Pipeline
constructor
A new instance of Pipeline.
- #shutdown? ⇒ Boolean
- #without_reconnect(&block) ⇒ Object
- #without_reconnect? ⇒ Boolean
Constructor Details
#initialize ⇒ Pipeline
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
#futures ⇒ Object (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 |
#commands ⇒ Object
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
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
17 18 19 |
# File 'lib/redis/pipeline.rb', line 17 def without_reconnect? @without_reconnect end |