method
cache_sql
v7.2.3 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::QueryCache
cache_sql(sql, name, binds)private
No documentation available.
# File activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 289
def cache_sql(sql, name, binds)
key = binds.empty? ? sql : [sql, binds]
result = nil
hit = true
@lock.synchronize do
result = query_cache.compute_if_absent(key) do
hit = false
yield
end
end
if hit
ActiveSupport::Notifications.instrument(
"sql.active_record",
cache_notification_info(sql, name, binds)
)
end
result.dup
end