/** * 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; }
/** * @param \Doctrine\ORM\Persisters\Entity\EntityPersister $persister The entity persister to cache. * @param \Doctrine\ORM\Cache\Region $region The entity cache region. * @param \Doctrine\ORM\EntityManagerInterface $em The entity manager. * @param \Doctrine\ORM\Mapping\ClassMetadata $class The entity metadata. */ public function __construct(EntityPersister $persister, Region $region, EntityManagerInterface $em, ClassMetadata $class) { $configuration = $em->getConfiguration(); $cacheConfig = $configuration->getSecondLevelCacheConfiguration(); $cacheFactory = $cacheConfig->getCacheFactory(); $this->class = $class; $this->region = $region; $this->persister = $persister; $this->cache = $em->getCache(); $this->regionName = $region->getName(); $this->uow = $em->getUnitOfWork(); $this->metadataFactory = $em->getMetadataFactory(); $this->cacheLogger = $cacheConfig->getCacheLogger(); $this->timestampRegion = $cacheFactory->getTimestampRegion(); $this->hydrator = $cacheFactory->buildEntityHydrator($em, $class); $this->timestampKey = new TimestampCacheKey($this->class->getTableName()); }
/** * {@inheritdoc} */ public function getCache() { return $this->wrapped->getCache(); }