method
compute_if_absent
rails latest stable - Class:
ActiveRecord::ConnectionAdapters::QueryCache::Store
compute_if_absent(key)public
No documentation available.
# File activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 67
def compute_if_absent(key)
check_version
return yield unless @enabled
if entry = @map.delete(key)
return @map[key] = entry
end
if @max_size && @map.size >= @max_size
@map.shift # evict the oldest entry
end
@map[key] ||= yield
end