Class: ActiveRecord::ConnectionAdapters::QueryCache::QueryCacheRegistry
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/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.
Class Method Summary
- .new ⇒ QueryCacheRegistry constructor
Instance Method Summary
Constructor Details
.new ⇒ QueryCacheRegistry
# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 116
def initialize @mutex = Mutex.new @map = ConnectionPool::WeakThreadKeyMap.new end
Instance Method Details
#clear
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 127
def clear @map.synchronize do @map.clear end end
#compute_if_absent(context)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 121
def compute_if_absent(context) @map[context] || @mutex.synchronize do @map[context] ||= yield end end