Created
April 18, 2013 15:47
-
-
Save eb-eoliveira/5413804 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final public function findReadOnly($id, $fetchMode = self::FETCH_LAZY_MODE) | |
{ | |
// initialize answer | |
$res = null; | |
// calculate key | |
$cacheKey = self::getCacheKey($this->getEntityName(), $id, $fetchMode); | |
// check cache | |
if (($cacheRes = $this->fetchFromCache($cacheKey)) !== false) { | |
// cache hit | |
$res = $this->getEntityManager()->merge($cacheRes); | |
// just for debug purposes | |
if ($this->logger instanceof LoggerInterface) { | |
$this->logger->debug('Find read only entity cache hit ' . $cacheKey); | |
} | |
} elseif (is_object($dbRes = $this->findReadOnlyDb($id, $fetchMode))) { | |
// store into cache | |
$this->storeIntoCache( | |
$cacheKey, | |
$dbRes, | |
$this->getExpiration($fetchMode) | |
); | |
$res = $dbRes; | |
} | |
return $res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment