123456789_123456789_123456789_123456789_123456789_

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

Class Method Summary

Instance Method Summary

Constructor Details

.newQueryCacheRegistry

[ GitHub ]

  
# File 'activerecord/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

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb', line 109

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 103

def compute_if_absent(context)
  @map[context] || @mutex.synchronize do
    @map[context] ||= yield
  end
end