class Redic::Pool
Constants
- VERSION
Attributes
pool[R]
url[R]
Public Class Methods
new(url, options = {})
click to toggle source
# File lib/redic/pool.rb, line 10 def initialize(url, options = {}) @url = url @pool = ConnectionPool.new(size: options.fetch(:size, 10)) { Redic.new(url) } @id = "redic-pool-#{object_id}" end
Public Instance Methods
call(*args)
click to toggle source
# File lib/redic/pool.rb, line 17 def call(*args) @pool.with do |client| client.call(*args) end end
commit()
click to toggle source
# File lib/redic/pool.rb, line 28 def commit @pool.with do |client| Thread.current[@id].each do |args| client.queue(*args) end result = client.commit Thread.current[@id].clear result end end
queue(*args)
click to toggle source
# File lib/redic/pool.rb, line 23 def queue(*args) Thread.current[@id] || (Thread.current[@id] = []) Thread.current[@id] << args end