Module: ActiveRecord::ConnectionAdapters::QueryCache::ConnectionPoolConfiguration
- Included in:
- ConnectionPool
- Defined in:
- lib/active_record/connection_adapters/abstract/query_cache.rb
Overview
:nodoc:
Instance Method Summary collapse
- #checkout_and_verify(connection) ⇒ Object
- #clear_query_cache ⇒ Object
- #dirties_query_cache ⇒ Object
-
#disable_query_cache(dirties: true) ⇒ Object
Disable the query cache within the block.
- #disable_query_cache! ⇒ Object
- #enable_query_cache ⇒ Object
- #enable_query_cache! ⇒ Object
- #initialize ⇒ Object
- #query_cache ⇒ Object
- #query_cache_enabled ⇒ Object
Instance Method Details
#checkout_and_verify(connection) ⇒ Object
96 97 98 99 100 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 96 def checkout_and_verify(connection) super connection.query_cache ||= query_cache connection end |
#clear_query_cache ⇒ Object
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 139 def clear_query_cache if @pinned_connection # With transactional fixtures, and especially systems test # another thread may use the same connection, but with a different # query cache. So we must clear them all. @thread_query_caches.each_value(&:clear) else query_cache.clear end end |
#dirties_query_cache ⇒ Object
135 136 137 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 135 def dirties_query_cache query_cache.dirties end |
#disable_query_cache(dirties: true) ⇒ Object
Disable the query cache within the block.
103 104 105 106 107 108 109 110 111 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 103 def disable_query_cache(dirties: true) cache = query_cache old_enabled, cache.enabled, old_dirties, cache.dirties = cache.enabled, false, cache.dirties, dirties begin yield ensure cache.enabled, cache.dirties = old_enabled, old_dirties end end |
#disable_query_cache! ⇒ Object
127 128 129 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 127 def disable_query_cache! query_cache.enabled, query_cache.dirties = false, true end |
#enable_query_cache ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 113 def enable_query_cache cache = query_cache old_enabled, cache.enabled, old_dirties, cache.dirties = cache.enabled, true, cache.dirties, true begin yield ensure cache.enabled, cache.dirties = old_enabled, old_dirties end end |
#enable_query_cache! ⇒ Object
123 124 125 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 123 def enable_query_cache! query_cache.enabled, query_cache.dirties = true, true end |
#initialize ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 82 def initialize(...) super @thread_query_caches = Concurrent::Map.new(initial_capacity: @size) @query_cache_max_size = \ case query_cache = db_config&.query_cache when 0, false nil when Integer query_cache when nil DEFAULT_SIZE end end |
#query_cache ⇒ Object
150 151 152 153 154 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 150 def query_cache @thread_query_caches.compute_if_absent(ActiveSupport::IsolatedExecutionState.context) do Store.new(@query_cache_max_size) end end |
#query_cache_enabled ⇒ Object
131 132 133 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 131 def query_cache_enabled query_cache.enabled end |