instance method
cache_sql
Ruby on Rails 7.2.3
Since v2.2.3 PrivateSignature
cache_sql(sql, name, binds)
No documentation comment.
Parameters
-
sqlreq -
namereq -
bindsreq
Source
# 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
Defined in activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb line 289
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::QueryCache