我正在尝试通过使用结果缓存来提高使用Doctrine 2.0的应用程序的性能。
查询上的setResultCacheImpl()和useResultCache(true)与APC一起用作缓存。
调试我可以看到它\Doctrine\ORM\AbstractQuery->execute
被调用了,但是从没有找到缓存的数据。原因是$cached[$id]
从缓存中读取数据时从未设置。看下面的Doctrine代码,我也看不到$cached[$id]
应该如何设置:
// Check result cache
if ($this->_useResultCache && $cacheDriver = $this->getResultCacheDriver()) {
list($id, $hash) = $this->getResultCacheId();
$cached = $this->_expireResultCache ? false : $cacheDriver->fetch($id);
if ($cached === false || !isset($cached[$id])) {
// Cache miss.
$stmt = $this->_doExecute();
$result = $this->_em->getHydrator($this->_hydrationMode)->hydrateAll(
$stmt, $this->_resultSetMapping, $this->_hints
);
$cacheDriver->save($id, $result, $this->_resultCacheTTL);
return $result;
} else {
// Cache hit.
return $cached[$id];
}
}
任何的想法?
要解决此问题,您需要从Doctrine 2.0.x存储库中应用修复程序:https : //github.com/doctrine/doctrine2/commit/4271706cabdf6f7a99ffbe6aad0efcec1584f562
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句