]> git.saurik.com Git - redis.git/blob - client-libraries/ruby/lib/pipeline.rb
__P completely removed from pqsort.c/h
[redis.git] / client-libraries / ruby / lib / pipeline.rb
1 require "redis"
2
3 class Redis
4 class Pipeline < Redis
5 BUFFER_SIZE = 50_000
6
7 def initialize(redis)
8 @redis = redis
9 @commands = []
10 end
11
12 def execute_command(data)
13 @commands << data
14 write_and_read if @commands.size >= BUFFER_SIZE
15 end
16
17 def finish
18 write_and_read
19 end
20
21 def write_and_read
22 @redis.execute_command(@commands.join, true)
23 @redis.read_socket
24 @commands.clear
25 end
26
27 end
28 end