Class: Redic::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/redic/pool.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Pool

Returns a new instance of Pool.



9
10
11
# File 'lib/redic/pool.rb', line 9

def initialize(url, options = {})
  @pool = ConnectionPool.new(size: options.fetch(:size, 10)) { Redic.new(url) }
end

Instance Attribute Details

#poolObject (readonly)

Returns the value of attribute pool.



7
8
9
# File 'lib/redic/pool.rb', line 7

def pool
  @pool
end

Instance Method Details

#call(*args) ⇒ Object



13
14
15
16
17
# File 'lib/redic/pool.rb', line 13

def call(*args)
  @pool.with do |client|
    client.call(*args)
  end
end

#with(&block) ⇒ Object



19
20
21
# File 'lib/redic/pool.rb', line 19

def with(&block)
  @pool.with(&block)
end