Module: ActiveRecord::ConnectionAdapters::QueryCache::ConnectionPoolConfiguration
Do not use. This module is for internal use only.
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Defined in: | activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb |
Instance Method Summary
- #build_query_cache
- #checkout_and_verify(connection)
- #clear_query_cache
- #dirties_query_cache
-
#disable_query_cache(dirties: true)
Disable the query cache within the block.
- #disable_query_cache!
- #enable_query_cache
- #enable_query_cache!
- #initialize
- #prepare_query_cache(cache)
- #query_cache
- #query_cache_enabled
- #reset_query_cache!
Instance Method Details
#build_query_cache
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 195
def build_query_cache # :nodoc: Store.new(@query_cache_version, @query_cache_max_size).tap { |cache| prepare_query_cache(cache) } end
#checkout_and_verify(connection)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 131
def checkout_and_verify(connection) super connection.query_cache ||= query_cache connection end
#clear_query_cache
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 181
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
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 177
def dirties_query_cache query_cache.dirties end
#disable_query_cache(dirties: true)
Disable the query cache within the block.
# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 138
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!
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 163
def disable_query_cache! query_cache.enabled = false query_cache.dirties = true end
#enable_query_cache
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 148
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!
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 158
def enable_query_cache! query_cache.enabled = true query_cache.dirties = true end
#initialize
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 117
def initialize(...) super @query_cache_version = Concurrent::AtomicFixnum.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
#prepare_query_cache(cache)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 199
def prepare_query_cache(cache) # :nodoc: cache.enabled = QueryCache.enabled_by_default && db_config&.query_cache != false cache.dirties = true cache.clear end
#query_cache
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 191
def query_cache ConnectionPool.used_pools!.query_cache_for(self) end
#query_cache_enabled
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 173
def query_cache_enabled query_cache.enabled end
#reset_query_cache!
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 168
def reset_query_cache! # :nodoc: prepare_query_cache(query_cache) clear_query_cache end