Skip to content

Commit

Permalink
修正cache
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Jul 19, 2019
1 parent d35ba14 commit f6501b9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/CachedReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Doctrine\Common\Annotations\Reader;
use ReflectionClass;
use think\App;
use think\Cache;
use think\cache\Driver;

class CachedReader implements Reader
{
Expand All @@ -20,7 +20,7 @@ class CachedReader implements Reader
private $loadedAnnotations = [];

/**
* @var Cache
* @var Driver
*/
private $cache;

Expand Down Expand Up @@ -146,10 +146,8 @@ public function clearLoadedAnnotations()

private function fetchFromCache($cacheKey, ReflectionClass $class)
{
if (($data = $this->cache->get($cacheKey)) !== false) {
if (!$this->debug || $this->isCacheFresh($cacheKey, $class)) {
return $data;
}
if ((!$this->debug || $this->isCacheFresh($cacheKey, $class)) && $this->cache->has($cacheKey)) {
return $this->cache->get($cacheKey, false);
}

return false;
Expand Down

0 comments on commit f6501b9

Please sign in to comment.