Method: Mongoid::Criterion::Optional#cache
- Defined in:
- lib/mongoid/criterion/optional.rb
#cache ⇒ Criteria
Tells the criteria that the cursor that gets returned needs to be cached. This is so multiple iterations don’t hit the database multiple times, however this is not advisable when working with large data sets as the entire results will get stored in memory.
33 34 35 |
# File 'lib/mongoid/criterion/optional.rb', line 33 def cache clone.tap { |crit| crit..merge!(:cache => true) } end |