[DDC-1766] Explain details of Hydration cache, introduce AbstractQuery#setResultCacheProfile method
This commit is contained in:
parent
c32a77e6be
commit
d31c7f5e2b
@ -311,6 +311,12 @@ abstract class AbstractQuery
|
|||||||
* If no result cache driver is set in the QueryCacheProfile, the default
|
* If no result cache driver is set in the QueryCacheProfile, the default
|
||||||
* result cache driver is used from the configuration.
|
* 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
|
* @example
|
||||||
* $lifetime = 100;
|
* $lifetime = 100;
|
||||||
* $resultKey = "abc";
|
* $resultKey = "abc";
|
||||||
@ -338,6 +344,25 @@ abstract class AbstractQuery
|
|||||||
return $this->_hydrationCacheProfile;
|
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.
|
* Defines a cache driver to be used for caching result sets and implictly enables caching.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user