Class: ActiveRecord::QueryCache
- Defined in:
- activerecord/lib/active_record/query_cache.rb
Overview
Active Record Query Cache
Defined Under Namespace
Modules: ClassMethods Classes: BodyProxy
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.
26 27 28 |
# File 'activerecord/lib/active_record/query_cache.rb', line 26 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'activerecord/lib/active_record/query_cache.rb', line 60 def call(env) old = ActiveRecord::Base.connection.query_cache_enabled ActiveRecord::Base.connection.enable_query_cache! status, headers, body = @app.call(env) [status, headers, BodyProxy.new(old, body, ActiveRecord::Base.connection_id)] rescue Exception => e ActiveRecord::Base.connection.clear_query_cache unless old ActiveRecord::Base.connection.disable_query_cache! end raise e end |