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



286
287
288
289
290
291
292
293
294
295
296
# File 'lib/mongo/query_cache.rb', line 286

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