Class: OTR::ActiveRecord::QueryCache
- Inherits:
-
Object
- Object
- OTR::ActiveRecord::QueryCache
- Defined in:
- lib/otr-activerecord/middleware/query_cache.rb
Overview
Rack middleware to enable ActiveRecord’s query cache for each request.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ QueryCache
constructor
A new instance of QueryCache.
Constructor Details
#initialize(app) ⇒ QueryCache
Returns a new instance of QueryCache.
7 8 9 |
# File 'lib/otr-activerecord/middleware/query_cache.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/otr-activerecord/middleware/query_cache.rb', line 11 def call(env) state = nil state = ::ActiveRecord::QueryCache.run @app.call(env) ensure ::ActiveRecord::QueryCache.complete(state) if state end |