I use Doctrine 2 ORM in a Zend Framework 2 project and I wanted to clarify some details about caching.
Doctrine config looks like
return array(
'doctrine' => array(
'driver' => array(
'application_entities' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'doctrine_cache_entities', // 1
'paths' => array(__DIR__ . '/../src/Application/Entity')
),
'orm_default' => array(
'drivers' => array(
'Application\Entity' => 'application_entities',
),
),
),
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'doctrine_cache_metadata', // 2
'query_cache' => 'doctrine_cache_query', // 3
'result_cache' => 'doctrine_cache_result', // 4
'hydration_cache' => 'doctrine_cache_hydration', // 5
)
),
),
);
Here we can see 5 different types of cache:
But there are only 3 options in Doctrine console tool to clear the cache:
So how can I clear the rest cache (especially entities cache) considering that it can be stored in different places, not necessarily in the filesystem.
And the second question:
Should all these caches be enabled in production together (the question is mainly about Entities and Metadata cache since they seem to contain similar data)?
**N.B.* The chache
info for the driver configuration comes from here
The 1st cache you described (Entity Cache) is actually the metadata cache and allows you to override the type of caching used on entities in a paticulate module, therefore you clear the entity cache by running orm:clear-cache:metadata.
With the hydration cache, I am inclined to say that it is linked to the result cache.
From the documentation, the hydration cache is used when merging entities back into the Unit of Work, and given how expensive that is, it should be avoided, however if you were to use the hydration cache, intuition would suggest that by running orm:clear-cache:result you would clear the hydration cache.
Hydration cache: https://groups.google.com/forum/#!topic/doctrine-user/V4G4rRF7Ls4
Merging Entities into UofW: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-objects.html#merging-entities
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With