Doctrine MongoDB result caching Doctrine MongoDB result caching mongodb mongodb

Doctrine MongoDB result caching


Doctrine MongoDB ODM does not support query caching, so this is definitely something you'd need to handle in your application for the time being.

If you have an issue with heavy objects, it's most likely the Proxy instances (for referenced documents), as those contain references to internal Doctrine services (e.g. UnitOfWork). If you wanted to cache these efficiently, you'd essentially need to cull those references before storage and then restore them after fetching from the cache. That's likely to be more trouble than its worth, but it would reduce the objects to the data containers that you want.

Alternatively, if you're using the query builder, you could disable hydration and then implement caching for returned array results. Beyond that, you could look into caching views in your application (this is ideal in Symfony2, where one request might hit several controllers, each of which can apply their own caching rules and optionally utilize ESI).