Class: ActiveRecord::QueryCache
- Inherits:
-
Object
- Object
- 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)
- - (Object) call(env)
-
- (QueryCache) initialize(app)
constructor
A new instance of QueryCache.
Constructor Details
- (QueryCache) initialize(app)
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
- (Object) call(env)
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'activerecord/lib/active_record/query_cache.rb', line 58 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)] rescue Exception => e ActiveRecord::Base.connection.clear_query_cache unless old ActiveRecord::Base.connection.disable_query_cache! end raise e end |