]>
Commit | Line | Data |
---|---|---|
57172ffb | 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 get_response | |
13 | end | |
14 | ||
15 | def write(data) | |
16 | @commands << data | |
17 | write_and_read if @commands.size >= BUFFER_SIZE | |
18 | end | |
19 | ||
20 | def finish | |
21 | write_and_read | |
22 | end | |
23 | ||
24 | def write_and_read | |
25 | @redis.write @commands.join | |
26 | @redis.read_socket | |
27 | @commands.clear | |
28 | end | |
29 | ||
30 | end | |
31 | end |