O'Reilly logo

Learning Mongoid by Gautam Rege

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

IdentityMap

This section is relevant only if you are using Mongoid 3. IdentityMap has been removed in Mongoid 4 because it now includes Mongoid::Relations::Eager.

An IdentityMap pattern is a design pattern where the object gets loaded only once from the database, and is then stored in the map. So, the next lookup is directly from the map and hence faster. The IdentityMap pattern has been implemented in Mongoid (and removed in the latest version).

Note

Ignore the rest of this section if you use Mongoid4. Only if you are using Mongoid 3, is the remaining section relevant.

If enabled properly, IdentityMap can greatly improve the performance of queries. Whenever a document is loaded from the database, it is classified by class and ID kept in the IdentityMap ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required