Class: ActiveRecord::ConnectionAdapters::QueryCache::QueryCacheRegistry
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::QueryCache::QueryCacheRegistry
- Defined in:
- lib/active_record/connection_adapters/abstract/query_cache.rb
Overview
Each connection pool has one of these registries. They map execution contexts to query cache stores.
The keys of the internal map are threads or fibers (whatever ActiveSupport::IsolatedExecutionState.context returns), and their associated values are their respective query cache stores.
Instance Method Summary collapse
- #clear ⇒ Object
- #compute_if_absent(context) ⇒ Object
-
#initialize ⇒ QueryCacheRegistry
constructor
:nodoc:.
Constructor Details
#initialize ⇒ QueryCacheRegistry
:nodoc:
114 115 116 117 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 114 def initialize @mutex = Mutex.new @map = ConnectionPool::WeakThreadKeyMap.new end |
Instance Method Details
#clear ⇒ Object
125 126 127 128 129 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 125 def clear @map.synchronize do @map.clear end end |
#compute_if_absent(context) ⇒ Object
119 120 121 122 123 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 119 def compute_if_absent(context) @map[context] || @mutex.synchronize do @map[context] ||= yield end end |