How are Redis customers pipelining?

The Redis protocol documentation says:

A client can use the same connection to issue multiple commands. Pipeline support is supported, so you can send several commands with one write operation by the client, there is no need to read the server response to execute the next command. All answers can be read at the end.

However, I cannot find any example of how this is implemented. How does the Redis client implement pipelining?

+5
source share
3 answers

, TCP, , TCP , -by-one , . / , , .

, redis processInputBuffer()/processMultibulkBuffer() network.c, redis , ., , addReply()

+4

, , Ruby redis, redis-rb Python, redis-py, .

, TaylorOtwell, , , , redis MULTI/EXEC .

redis-rb ( redis.rb pipeline.rb):

def pipelined(options = {})
  synchronize do
    begin
      original, @client = @client, Pipeline.new
      yield
      if @client.commands.empty?
        []
      else
        original.call_pipelined(@client.commands, options)
      end
    ensure
      @client = original
    end
  end
end

def call_pipelined(commands, options = {})
  @commands.concat commands
  nil
end

redis-py, - Python. , .

+4

. redis- - , redis- , redis . , :

​​ . , , , . . ( ) TCP ( ) . , . , , , "" ( ). , , , .

Here is a blog post you can link to to get a better idea: http://nachivpn.blogspot.in/2014/11/redis-pipeline-explained.html

+2
source

All Articles