Class: ActiveRecord::ConnectionAdapters::QueryCache::QueryCacheRegistry
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::QueryCache::QueryCacheRegistry
- Defined in:
- lib/active_record/connection_adapters/abstract/query_cache.rb
Overview
:nodoc:
Instance Method Summary collapse
- #clear ⇒ Object
- #compute_if_absent(context) ⇒ Object
-
#initialize ⇒ QueryCacheRegistry
constructor
A new instance of QueryCacheRegistry.
Constructor Details
#initialize ⇒ QueryCacheRegistry
Returns a new instance of QueryCacheRegistry.
98 99 100 101 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 98 def initialize @mutex = Mutex.new @map = ConnectionPool::WeakThreadKeyMap.new end |
Instance Method Details
#clear ⇒ Object
109 110 111 112 113 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 109 def clear @map.synchronize do @map.clear end end |
#compute_if_absent(context) ⇒ Object
103 104 105 106 107 |
# File 'lib/active_record/connection_adapters/abstract/query_cache.rb', line 103 def compute_if_absent(context) @map[context] || @mutex.synchronize do @map[context] ||= yield end end |