29 lines
479 B
Ruby
Raw Normal View History

require "redis"
class Redis
class Pipeline < Redis
BUFFER_SIZE = 50_000
def initialize(redis)
@redis = redis
@commands = []
end
2009-06-10 00:08:10 +02:00
def execute_command(data)
@commands << data
write_and_read if @commands.size >= BUFFER_SIZE
end
2009-06-10 00:08:10 +02:00
def finish
write_and_read
end
def write_and_read
@redis.execute_command(@commands.join, true)
@redis.read_socket
@commands.clear
end
end
2009-05-26 18:10:50 +02:00
end