1
0
mirror of synced 2025-01-18 06:21:40 +03:00

[2.0] Implemented single cache lookup in AnnotationReader

This commit is contained in:
guilhermeblanco 2010-03-30 20:25:51 +00:00
parent 62e7146d2d
commit 517bb66468

View File

@ -106,10 +106,9 @@ class AnnotationReader
{
$cacheKey = $class->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey);
// Attempt to grab data from cache
if (($data = $this->_cache->fetch($cacheKey)) !== false) {
return $data;
}
$annotations = $this->_parser->parse($class->getDocComment(), "class ".$class->getName());
@ -143,12 +142,11 @@ class AnnotationReader
{
$cacheKey = $property->getDeclaringClass()->getName() . '$' . $property->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey);
// Attempt to grab data from cache
if (($data = $this->_cache->fetch($cacheKey)) !== false) {
return $data;
}
$context = "property ".$property->getDeclaringClass()->getName()."::\$".$property->getName();
$annotations = $this->_parser->parse($property->getDocComment(), $context);
$this->_cache->save($cacheKey, $annotations, null);
@ -181,10 +179,9 @@ class AnnotationReader
{
$cacheKey = $method->getDeclaringClass()->getName() . '#' . $method->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey);
// Attempt to grab data from cache
if (($data = $this->_cache->fetch($cacheKey)) !== false) {
return $data;
}
$context = "method ".$method->getDeclaringClass()->getName()."::".$method->getName()."()";