Sha256: 2c23b01b26f5840fe9b2f26f3a38579cd407b43cc77b0bc1cd6783eba8e0fb67
Contents?: true
Size: 903 Bytes
Versions: 12
Compression:
Stored size: 903 Bytes
Contents
# Set and access +Resque.redis+ in a thread-safe way. module Resque::ThreadSafeRedis thread_mattr_accessor :thread_resque_override def self.resque_override self.thread_resque_override ||= ResqueOverride.new end def redis Resque::ThreadSafeRedis.resque_override.data_store_override || super end alias :data_store :redis def with_per_thread_redis_override(redis_instance, &block) Resque::ThreadSafeRedis.resque_override.enable_with(redis_instance, &block) end class ResqueOverride include Resque attr_accessor :data_store_override def enable_with(server, &block) previous_redis, previous_data_store_override = redis, data_store_override self.redis = server self.data_store_override = @data_store block.call ensure self.redis = previous_redis self.data_store_override = previous_data_store_override end end end
Version data entries
12 entries across 12 versions & 1 rubygems