From b97f3f4f739cdb808a8a8b58d8aa05e8b6e095cb Mon Sep 17 00:00:00 2001 From: Mike Pastore Date: Tue, 24 Oct 2017 18:15:27 -0500 Subject: [PATCH] Allow passing Redic timeout and other ConnectionPool options. --- lib/redic/pool.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/redic/pool.rb b/lib/redic/pool.rb index 4acf428..1dde0b9 100644 --- a/lib/redic/pool.rb +++ b/lib/redic/pool.rb @@ -7,9 +7,11 @@ class Redic::Pool attr :url attr :pool - def initialize(url, options = {}) + def initialize(url = "redis://127.0.0.1:6379", timeout = 10_000_000, **opts) + opts[:size] = 10 unless opts.key?(:size) + @url = url - @pool = ConnectionPool.new(size: options.fetch(:size, 10)) { Redic.new(url) } + @pool = ConnectionPool.new(opts) { Redic.new(url, timeout) } @id = "redic-pool-#{object_id}" end