class ActionSubscriber::Middleware::ActiveRecord::QueryCache
Constants
- CURRENT_CONNECTION
Public Class Methods
new(app)
click to toggle source
# File lib/action_subscriber/middleware/active_record/query_cache.rb, line 7 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/action_subscriber/middleware/active_record/query_cache.rb, line 11 def call(env) connection = ::Thread.current[CURRENT_CONNECTION] = ::ActiveRecord::Base.connection enabled = connection.query_cache_enabled connection.enable_query_cache! @app.call(env) ensure restore_query_cache_settings(enabled) end
Private Instance Methods
restore_query_cache_settings(enabled)
click to toggle source
# File lib/action_subscriber/middleware/active_record/query_cache.rb, line 23 def restore_query_cache_settings(enabled) ::Thread.current[CURRENT_CONNECTION].clear_query_cache ::Thread.current[CURRENT_CONNECTION].disable_query_cache! unless enabled ::Thread.current[CURRENT_CONNECTION] = nil end