class ActiveRecord::StatementCache::Substitute
:nodoc:
:nodoc:
cache.execute([“my book”], ClothingItem.lease_connection)
And pass the bind values as the first argument of execute
call.
end
Book.where(name: params.bind)
cache = StatementCache.create(ClothingItem.lease_connection) do |params|
block parameter.
If you want to cache the statement without the values you can use the bind
method of the
call the cached relation gets duped. Database is queried when to_a
is called on the relation.
The relation returned by the block is cached, and for each
cache.execute([], ClothingItem.lease_connection)
method:
The cached statement is executed by using the
end
Book.where(name: “my book”).where(“author_id > 3”)
cache = StatementCache.create(ClothingItem.lease_connection) do |params|
Initializing the cache is done by passing the statement in the create block:
Statement cache is used to cache a single statement in order to avoid creating the AST again.