Ruby on Rails latest stable (v4.1.8) - 0 notes - Superclass: Object

Statement cache is used to cache a single statement in order to avoid creating the AST again. Initializing the cache is done by passing the statement in the initialization block:

cache = ActiveRecord::StatementCache.new do
  Book.where(name: "my book").limit(100)

The cached statement is executed by using the execute method:


The relation returned by the block is cached, and for each execute call the cached relation gets duped. Database is queried when to_a is called on the relation.

Show files where this class is defined (1 file)
Register or log in to add new notes.