redis/redis-rb — pull request #204 by betamatt (2012-03-29 20:41:17+00:00)
Title: Yield connection instance to pipelined blocks.

This patch is against 2.2.2 and will require a 2.2 maintenance branch, which I hope you'll create.

Yielding the connection instance to the pipeline block allows pipelines to be safely used with transparent connection proxies, like the EM-synchrony ConnectionPool class. These proxies assume that any access to connection, such as `redis.pipeline { }` will allocate and the release a connection from the pool.

Bad case:

redis.pipeline do <--- reservers a connection from the pool
redis.set 'x', 1 <--- each subsequent access to redis attempts to reserve another connection
redis.set 'y', 2
end

Good case:

redis.pipeline do |p|
p.set 'x', 1 <---- uses the same reserved connection for each command
p.set 'y', 2
end