【问题标题】:Doctrine 2.0 query cache results can't be usedDoctrine 2.0 查询缓存结果无法使用
【发布时间】: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


    【解决方案1】:

    要解决此问题,您需要应用 Doctrine 2.0.x 存储库中的修复:https://github.com/doctrine/doctrine2/commit/4271706cabdf6f7a99ffbe6aad0efcec1584f562

    【讨论】:

      猜你喜欢
      • 2015-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-30
      • 1970-01-01
      • 2018-04-13
      • 1970-01-01
      相关资源
      最近更新 更多