Module: RedisKit::Resque

Defined in:
lib/redis-kit/resque.rb

Class Method Summary collapse

Class Method Details

.check_redisObject



27
28
29
30
31
# File 'lib/redis-kit/resque.rb', line 27

def self.check_redis
  if $redis != ::Resque.redis.redis
    $redis.client.disconnect
  end
end

.setupObject

Don’t clobber any existing hooks. Resque 1.24 changed the way hooks are stored, so we have to branch for that.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/redis-kit/resque.rb', line 10

def self.setup
  existing_hook = ::Resque.after_fork

  if existing_hook == nil || existing_hook.is_a?(Array)
    # resque >= 1.24 (or <= 1.23 with no existing hook)
    ::Resque.after_fork do |job|
      check_redis
    end
  elsif existing_hook.is_a?(Proc)
    # resque <= 1.23
    ::Resque.after_fork do |job|
      existing_hook.call( job )
      check_redis
    end
  end
end