class Oxblood::Pipeline
Redis
pipeling class. Commands
won't be send until {#sync} is called. Error responses won't be raised and should be checked manually in the responses array. @see redis.io/topics/pipelining#redis-pipelining
@example Basic workflow
pipeline = Pipeline.new(connection) pipeline.echo('ping') pipeline.ping pipeline.echo('!') pipeline.sync # => ["ping", "PONG", "!"]
Attributes
connection[R]
Public Class Methods
new(connection)
click to toggle source
# File lib/oxblood/pipeline.rb, line 21 def initialize(connection) @connection = connection @commands = Array.new end
Public Instance Methods
sync()
click to toggle source
Sends all commands at once and reads responses @return [Array] of responses
# File lib/oxblood/pipeline.rb, line 28 def sync serialized_commands = @commands.map { |c| Protocol.build_command(*c) } connection.socket.write(serialized_commands.join) Array.new(@commands.size) { connection.read_response } ensure @commands.clear end
Private Instance Methods
run(*command)
click to toggle source
# File lib/oxblood/pipeline.rb, line 38 def run(*command) @commands << command end