Module ActiveRecord::ConnectionAdapters::QueryCache
In: vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb

Methods

Public Class methods

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 15
15:         def dirties_query_cache(base, *method_names)
16:           method_names.each do |method_name|
17:             base.class_eval "def \#{method_name}_with_query_dirty(*args)\nclear_query_cache if @query_cache_enabled\n\#{method_name}_without_query_dirty(*args)\nend\n\nalias_method_chain :\#{method_name}, :query_dirty\n", __FILE__, __LINE__
18:           end
19:         end

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 5
 5:         def included(base)
 6:           base.class_eval do
 7:             attr_accessor :query_cache_enabled
 8:             alias_method_chain :columns, :query_cache
 9:             alias_method_chain :select_all, :query_cache
10:           end
11: 
12:           dirties_query_cache base, :insert, :update, :delete
13:         end

Public Instance methods

Enable the query cache within the block.

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 31
31:       def cache
32:         old, @query_cache_enabled = @query_cache_enabled, true
33:         @query_cache ||= {}
34:         yield
35:       ensure
36:         clear_query_cache
37:         @query_cache_enabled = old
38:       end

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 48
48:       def clear_query_cache
49:         @query_cache.clear if @query_cache
50:       end

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 60
60:       def columns_with_query_cache(*args)
61:         if @query_cache_enabled
62:           @query_cache["SHOW FIELDS FROM #{args.first}"] ||= columns_without_query_cache(*args)
63:         else
64:           columns_without_query_cache(*args)
65:         end
66:       end

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 52
52:       def select_all_with_query_cache(*args)
53:         if @query_cache_enabled
54:           cache_sql(args.first) { select_all_without_query_cache(*args) }
55:         else
56:           select_all_without_query_cache(*args)
57:         end
58:       end

Disable the query cache within the block.

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 41
41:       def uncached
42:         old, @query_cache_enabled = @query_cache_enabled, false
43:         yield
44:       ensure
45:         @query_cache_enabled = old
46:       end

[Validate]