method
cache_sql
v4.0.2 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::QueryCache
cache_sql(sql, binds)private
No documentation available.
# File activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb, line 69
def cache_sql(sql, binds)
result =
if @query_cache[sql].key?(binds)
ActiveSupport::Notifications.instrument("sql.active_record",
:sql => sql, :binds => binds, :name => "CACHE", :connection_id => object_id)
@query_cache[sql][binds]
else
@query_cache[sql][binds] = yield
end
# FIXME: we should guarantee that all cached items are Result
# objects. Then we can avoid this conditional
if ActiveRecord::Result === result
result.dup
else
result.collect { |row| row.dup }
end
end