Class: Upperkut::RedisPool

Inherits:
Object
  • Object
show all
Defined in:
lib/upperkut/redis_pool.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  pool_timeout: 1, # pool related option
  size: 2, # pool related option
  connect_timeout: 0.2,
  read_timeout: 5.0,
  write_timeout: 0.5,
  url: ENV['REDIS_URL']
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RedisPool

Returns a new instance of RedisPool.



15
16
17
18
19
20
21
# File 'lib/upperkut/redis_pool.rb', line 15

def initialize(options)
  @options      = DEFAULT_OPTIONS.merge(options)

  # Extract pool related options
  @size         = @options.delete(:size)
  @pool_timeout = @options.delete(:pool_timeout)
end

Instance Method Details

#createObject



23
24
25
26
27
# File 'lib/upperkut/redis_pool.rb', line 23

def create
  ConnectionPool.new(timeout: @pool_timeout, size: @size) do
    Redis.new(@options)
  end
end