Class: ActiveRecord::ConnectionAdapters::QueryCache::QueryCacheRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/abstract/query_cache.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeQueryCacheRegistry

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

#clearObject



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