Class: ActiveRecord::QueryCache

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/query_cache.rb

Overview

Active Record Query Cache

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.complete(state) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/active_record/query_cache.rb', line 35

def self.complete(state)
  enabled, connection_id = state

  ActiveRecord::Base.connection_id = connection_id
  ActiveRecord::Base.connection.clear_query_cache
  ActiveRecord::Base.connection.disable_query_cache! unless enabled
end

.install_executor_hooks(executor = ActiveSupport::Executor) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/active_record/query_cache.rb', line 43

def self.install_executor_hooks(executor = ActiveSupport::Executor)
  executor.register_hook(self)

  executor.to_complete do
    unless ActiveRecord::Base.connection.transaction_open?
      ActiveRecord::Base.clear_active_connections!
    end
  end
end

.runObject



26
27
28
29
30
31
32
33
# File 'lib/active_record/query_cache.rb', line 26

def self.run
  connection    = ActiveRecord::Base.connection
  enabled       = connection.query_cache_enabled
  connection_id = ActiveRecord::Base.connection_id
  connection.enable_query_cache!

  [enabled, connection_id]
end