Module: Mongo::QueryCache::Middleware::ActiveJob

Defined in:
lib/mongo/query_cache.rb

Overview

ActiveJob middleware that activates the query cache for each job.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



276
277
278
279
280
281
282
283
284
285
286
# File 'lib/mongo/query_cache.rb', line 276

def self.included(base)
  base.class_eval do
    around_perform do |_job, block|
      QueryCache.cache do
        block.call
      end
    ensure
      QueryCache.clear
    end
  end
end