Skip to content

Commit

Permalink
Yield a connection to pipeline blocks.
Browse files Browse the repository at this point in the history
Closes redis#205.
  • Loading branch information
djanowski committed Mar 30, 2012
1 parent 619256e commit 1c68738
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/redis.rb
Expand Up @@ -1770,7 +1770,7 @@ def pipelined
synchronize do |client|
begin
original, @client = @client, Pipeline.new
yield
yield(self)
original.call_pipeline(@client)
ensure
@client = original
Expand Down
8 changes: 8 additions & 0 deletions test/pipelining_commands_test.rb
Expand Up @@ -184,3 +184,11 @@

assert ["key"] == result.first
end

test "Pipeline yields a connection" do |r|
r.pipelined do |p|
p.set("foo", "bar")
end

assert_equal "bar", r.get("foo")
end

0 comments on commit 1c68738

Please sign in to comment.