1
0
mirror of synced 2025-01-18 06:21:40 +03:00

[DDC-1766] Explain details of Hydration cache, introduce AbstractQuery#setResultCacheProfile method

This commit is contained in:
Benjamin Eberlei 2012-04-04 23:55:14 +02:00
parent c32a77e6be
commit d31c7f5e2b

View File

@ -311,6 +311,12 @@ abstract class AbstractQuery
* If no result cache driver is set in the QueryCacheProfile, the default
* result cache driver is used from the configuration.
*
* Important: Hydration caching does NOT register entities in the
* UnitOfWork when retrieved from the cache. Never use result cached
* entities for requests that also flush the EntityManager. If you want
* some form of caching with UnitOfWork registration you should use
* {@see AbstractQuery::setResultCacheProfile()}.
*
* @example
* $lifetime = 100;
* $resultKey = "abc";
@ -338,6 +344,25 @@ abstract class AbstractQuery
return $this->_hydrationCacheProfile;
}
/**
* Set a cache profile for the result cache.
*
* If no result cache driver is set in the QueryCacheProfile, the default
* result cache driver is used from the configuration.
*
* @param \Doctrine\DBAL\Cache\QueryCacheProfile $profile
* @return \Doctrine\ORM\AbstractQuery
*/
public function setResultCacheProfile(QueryCacheProfile $profile = null)
{
if ( ! $profile->getResultCacheDriver()) {
$profile = $profile->setResultCacheDriver($this->_em->getConfiguration()->getResultCacheImpl());
}
$this->_queryCacheProfile = $profile;
return $this;
}
/**
* Defines a cache driver to be used for caching result sets and implictly enables caching.
*