class Redic
Attributes
client[R]
url[R]
Public Class Methods
new(url = "redis://127.0.0.1:6379", timeout = 10_000_000)
click to toggle source
# File lib/redic.rb, line 8 def initialize(url = "redis://127.0.0.1:6379", timeout = 10_000_000) @url = url @client = Redic::Client.new(url, timeout) @buffer = Hash.new { |h, k| h[k] = [] } end
Public Instance Methods
buffer()
click to toggle source
# File lib/redic.rb, line 14 def buffer @buffer[Thread.current.object_id] end
call(*args)
click to toggle source
# File lib/redic.rb, line 33 def call(*args) @client.connect do @client.write(args) @client.read end end
call!(*args)
click to toggle source
# File lib/redic.rb, line 40 def call!(*args) reply = call(*args) if RuntimeError === reply raise reply end return reply end
clear()
click to toggle source
# File lib/redic.rb, line 22 def clear @buffer.clear end
commit()
click to toggle source
# File lib/redic.rb, line 54 def commit @client.connect do buffer.map do |args| @client.write(args) end end ensure reset end
configure(url, timeout = 10_000_000)
click to toggle source
# File lib/redic.rb, line 26 def configure(url, timeout = 10_000_000) if @url != url @url = url @client.configure(url, timeout) end end
queue(*args)
click to toggle source
# File lib/redic.rb, line 50 def queue(*args) buffer << args end
quit()
click to toggle source
# File lib/redic.rb, line 72 def quit @client.quit end
reset()
click to toggle source
# File lib/redic.rb, line 18 def reset @buffer.delete(Thread.current.object_id) end
timeout()
click to toggle source
# File lib/redic.rb, line 64 def timeout @client.timeout end
timeout=(timeout)
click to toggle source
# File lib/redic.rb, line 68 def timeout=(timeout) @client.timeout = timeout end