Class: Workarea::QueryCacheMiddleware
- Inherits:
-
Object
- Object
- Workarea::QueryCacheMiddleware
- Defined in:
- app/middleware/workarea/query_cache_middleware.rb
Overview
Execute sidekiq jobs with query caches enabled. Each job can specify one or both query_caches to use via ‘query_cache`, `mongoid_query_cache`, or `elasticsearch_query_cache` options.
Defined Under Namespace
Classes: CacheOptions
Instance Method Summary collapse
- #call(worker, msg, queue) ⇒ Object
-
#initialize(options = {}) ⇒ QueryCacheMiddleware
constructor
A new instance of QueryCacheMiddleware.
Constructor Details
#initialize(options = {}) ⇒ QueryCacheMiddleware
Returns a new instance of QueryCacheMiddleware.
9 10 11 |
# File 'app/middleware/workarea/query_cache_middleware.rb', line 9 def initialize( = {}) @options = end |
Instance Method Details
#call(worker, msg, queue) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/middleware/workarea/query_cache_middleware.rb', line 13 def call(worker, msg, queue) = CacheOptions.new(worker.class.) return yield if .none? if .all? Mongoid::QueryCache.cache do Elasticsearch::QueryCache.cache do yield end end elsif .mongoid? Mongoid::QueryCache.cache { yield } elsif .elasticsearch? Elasticsearch::QueryCache.cache { yield } end ensure Mongoid::QueryCache.clear_cache Elasticsearch::QueryCache.clear_cache end |