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
148 149 150 151 152 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 148 def checkout_and_verify(connection) super connection.query_cache ||= query_cache connection end |
#clear_query_cache ⇒ Object
193 194 195 196 197 198 199 200 201 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 193 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. @query_cache_version.increment end query_cache.clear end |
#dirties_query_cache ⇒ Object
189 190 191 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 189 def dirties_query_cache query_cache.dirties end |
#disable_query_cache(dirties: true) ⇒ Object
Disable the query cache within the block.
155 156 157 158 159 160 161 162 163 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 155 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
180 181 182 183 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 180 def disable_query_cache! query_cache.enabled = false query_cache.dirties = true end |
#enable_query_cache ⇒ Object
165 166 167 168 169 170 171 172 173 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 165 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
175 176 177 178 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 175 def enable_query_cache! query_cache.enabled = true query_cache.dirties = true end |
#initialize ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 133 def initialize(...) super @query_cache_version = Concurrent::AtomicFixnum.new @thread_query_caches = QueryCacheRegistry.new @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
203 204 205 206 207 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 203 def query_cache @thread_query_caches.compute_if_absent(ActiveSupport::IsolatedExecutionState.context) do Store.new(@query_cache_version, @query_cache_max_size) end end |
#query_cache_enabled ⇒ Object
185 186 187 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 185 def query_cache_enabled query_cache.enabled end |