/** * @return string * * @throws \Doctrine\DBAL\Cache\CacheException */ public function getCacheKey() { if ($this->cacheKey === null) { throw CacheException::noCacheKey(); } return $this->cacheKey; }
/** * Executes a caching query. * * @param string $query The SQL query to execute. * @param array $params The parameters to bind to the query, if any. * @param array $types The types the previous parameters are in. * @param \Doctrine\DBAL\Cache\QueryCacheProfile $qcp The query cache profile. * * @return \Doctrine\DBAL\Driver\ResultStatement * * @throws \Doctrine\DBAL\Cache\CacheException */ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp) { $resultCache = $qcp->getResultCacheDriver() ?: $this->_config->getResultCacheImpl(); if (!$resultCache) { throw CacheException::noResultDriverConfigured(); } list($cacheKey, $realKey) = $qcp->generateCacheKeys($query, $params, $types); // fetch the row pointers entry if ($data = $resultCache->fetch($cacheKey)) { // is the real key part of this row pointers map or is the cache only pointing to other cache keys? if (isset($data[$realKey])) { $stmt = new ArrayStatement($data[$realKey]); } else { if (array_key_exists($realKey, $data)) { $stmt = new ArrayStatement(array()); } } } if (!isset($stmt)) { $stmt = new ResultCacheStatement($this->executeQuery($query, $params, $types), $resultCache, $cacheKey, $realKey, $qcp->getLifetime()); } $stmt->setFetchMode($this->defaultFetchMode); return $stmt; }