Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Explain that cache is not a real cache. #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions source/en/mongoid/docs/extras.haml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@
#!ruby
Person.where(first_name: "Franziska").cache

%p
The Mongoid cache is not a true cache - it simply keeps documents in
memory if you iterate over the same Criteria. That is, this will hit
the database twice:

:coderay
#!ruby
query = Person.where(first_name: "Jon").cache
query.each { |p| puts(p) }
query2 = Person.where(first_name: "Jon").cache
# This will make another database call because query2 is a new Criteria
query2.each { |p| puts(p) }

%section#paranoia
%h2
Paranoid Documents
Expand Down