From b0def215e1231745153209a28813b82f98c6bcaa Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Mon, 25 Mar 2013 21:06:51 -0700 Subject: [PATCH] Lazy load redis connection pool to avoid unicorn / passenger fork issues [#794] --- Changes.md | 4 ++-- lib/sidekiq.rb | 8 ++++---- lib/sidekiq/version.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Changes.md b/Changes.md index 8060daca..b6b215e6 100644 --- a/Changes.md +++ b/Changes.md @@ -1,9 +1,9 @@ Upcoming ----------- +- Lazy load Redis connection pool, you no longer need to specify +anything in Passenger or Unicorn's after_fork callback [#794] - Provides ability to hook onto failure after max retries failed. [jkassemi, #780] -- Delay on retry moved from constant proc to method call [lulalala, #784] -- DSM V compatible symptom definition of developer frustration [colszowka, #782] - Fix bug in pagination link to last page [pitr, #774] - Upstart scripts for multiple Sidekiq instances [dariocravero, #763] - Use select via pipes instead of poll to catch signals [mrnugget, #761] diff --git a/lib/sidekiq.rb b/lib/sidekiq.rb index 7ba2c153..362270d0 100644 --- a/lib/sidekiq.rb +++ b/lib/sidekiq.rb @@ -68,15 +68,15 @@ module Sidekiq def self.redis(&block) raise ArgumentError, "requires a block" if !block - @redis ||= Sidekiq::RedisConnection.create + @redis ||= Sidekiq::RedisConnection.create(@hash || {}) @redis.with(&block) end def self.redis=(hash) + return @redis = hash if hash.is_a?(ConnectionPool) + if hash.is_a?(Hash) - @redis = RedisConnection.create(hash) - elsif hash.is_a?(ConnectionPool) - @redis = hash + @hash = hash else raise ArgumentError, "redis= requires a Hash or ConnectionPool" end diff --git a/lib/sidekiq/version.rb b/lib/sidekiq/version.rb index 3e4e0055..81499b20 100644 --- a/lib/sidekiq/version.rb +++ b/lib/sidekiq/version.rb @@ -1,3 +1,3 @@ module Sidekiq - VERSION = "2.8.0" + VERSION = "2.9.0" end