Class: Redis
- Inherits:
-
Object
show all
- Defined in:
- lib/redis/structured-multi.rb
Defined Under Namespace
Classes: ReceiptedPipeline
Instance Method Summary
collapse
Instance Method Details
#pipelined_with_receipts(options = {}) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/redis/structured-multi.rb', line 84
def pipelined_with_receipts(options = {})
synchronize do
begin
original, @client = @client, ReceiptedPipeline.new
yield
unless @client.commands.empty?
receipted_pipeline = @client
pipeline_reply = original.call_pipelined(@client.commands, options)
mbulk_reply = pipeline_reply.last
ReceiptedPipeline::Thunk.new(receipted_pipeline, mbulk_reply)
end
ensure
@client = original
end
end
end
|
#structured_multi ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/redis/structured-multi.rb', line 102
def structured_multi
synchronize do
structure = nil
pipeline_thunk = pipelined_with_receipts(:raise => false) do
@client.call_without_reply([:multi])
structure = yield(self)
@client.call_without_reply([:exec])
end
structure.eqfmap(pipeline_thunk){ |receipt| pipeline_thunk[ receipt ] }
end
end
|