Sha256: 04bac46b39a27291a7d318dd51e809b2c7f97d741778e29b0289a95ce6f7781b

Contents?: true

Size: 717 Bytes

Versions: 2

Compression:

Stored size: 717 Bytes

Contents

require 'connection_pool'
require 'redis'

module Upperkut
  class RedisPool

    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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
upperkut-0.7.0 lib/upperkut/redis_pool.rb
upperkut-0.6.0 lib/upperkut/redis_pool.rb