【发布时间】:2013-08-05 12:16:29
【问题描述】:
我正在尝试通过利用 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