/** * Load from second level cache or executes the query and put into cache. * * @param ArrayCollection|array|null $parameters * @param integer|null $hydrationMode * * @return mixed */ private function executeUsingQueryCache($parameters = null, $hydrationMode = null) { $rsm = $this->getResultSetMapping(); $querykey = new QueryCacheKey($this->getHash(), $this->lifetime, $this->cacheMode ?: Cache::MODE_NORMAL); $queryCache = $this->_em->getCache()->getQueryCache($this->cacheRegion); $result = $queryCache->get($querykey, $rsm, $this->_hints); if ($result !== null) { if ($this->cacheLogger) { $this->cacheLogger->queryCacheHit($queryCache->getRegion()->getName(), $querykey); } return $result; } $result = $this->executeIgnoreQueryCache($parameters, $hydrationMode); $cached = $queryCache->put($querykey, $rsm, $result, $this->_hints); if ($this->cacheLogger) { $this->cacheLogger->queryCacheMiss($queryCache->getRegion()->getName(), $querykey); if ($cached) { $this->cacheLogger->queryCachePut($queryCache->getRegion()->getName(), $querykey); } } return $result; }
/** * {@inheritDoc} * * @static */ public static function getCache() { return \Doctrine\ORM\EntityManager::getCache(); }