检查编译缓存是否有效
@param string  $cacheFile 缓存的文件名
@param int     $cacheTime 缓存时间
@return boolean
345090
public function check($cacheFile, $cacheTime)
    {
        // 缓存文件不存在, 直接返回false
        if (!file_exists($cacheFile)) {
            return false;
        }

        if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) {
            // 缓存是否在有效期
            return false;
        }

        return true;
    }
831989
private function isExpired(CacheItemInterface $item, DateTime $time = null)
    {
        $time = $time ?: new DateTime();
        return ($time > $item->getExpiresAt());
    }
107778
File getCacheFile(TemplateClass tc) {
        String id = cacheFileName(tc, ".rythm");
        return getCacheFile(id);
    }
762543
public function isExist($cacheName, $cacheDir = false)
    {
        $cacheDir = $cacheDir == false ? self::$cacheDir : $cacheDir;
        $dir = $cacheDir."/".$cacheName;

        return file_exists($dir);
    }
487176
public function setCacheFile(string $cacheFile) : Router
    {
        if ($cacheFile == '') {
            $this->cacheFile = false;

            return $this;
        }

        $spl    = new \SplFileInfo($cacheFile);
        $splDir = $spl->getPathInfo();
        if (! $splDir->isWritable()) {
            throw new \RuntimeException(
                'Cache file directory is not writable',
                E_WARNING
            );
        }
        if ($spl->getRealPath() && ! $spl->isFile()) {
            throw new \RuntimeException(
                sprintf(
                    'Cache file is not a file %s given',
                    $spl->getType()
                ),
                E_WARNING
            );
        }

        if (! $spl->getRealPath()) {
            $spl = new \SplFileInfo($splDir->getRealPath() . DIRECTORY_SEPARATOR . $spl->getBasename());
        }

        $this->cacheFile = $spl->__toString();
        unset($spl, $splDir);

        return $this;
    }
1263926
public function read($cacheFile, $vars = [])
    {
        if (!empty($vars) && is_array($vars)) {
            // 模板阵列变量分解成为独立变量
            if (isset($vars['cacheFile'])) {
                $_think_cacheFile = $cacheFile;
                $cacheFile        = $vars['cacheFile'];
                unset($vars['cacheFile'], $vars['_think_cacheFile']);
                extract($vars);
                include $_think_cacheFile;
                return;
            }
            extract($vars);
        }

        //载入模版缓存文件
        include $cacheFile;
    }
1361127
public function getCache() 
    {

        // make sure filters are parsed again if cache expired
        if (file_exists($this->path) && (time()-filectime($this->path)) < 
            $this->config['expiration_time']) {
            $data = unserialize(file_get_contents($this->path));
              return $data;
        }

        return false;
    }
1310381
public function cache($file, $content, $timestamp = null)
    {
        if (!$cachePath = $this->cachePath()) {
            throw new JitException('Error, any cache path has been defined.');
        }
        $path = $cachePath . DS . ltrim(preg_replace('~:~', '', $file), DS);

        if (!@file_exists(dirname($path))) {
            mkdir(dirname($path), 0755, true);
        }

        if (file_put_contents($path, $content) === false) {
            throw new JitException("Unable to create a cached file at `'{$file}'`.");
        }
        if ($timestamp) {
            touch($path, $timestamp);
        }
        return $path;
    }
745882
protected function checkCache($originalFile, $cacheFile)
    {
        if (! $ret = parent::checkCache($originalFile, $cacheFile)) {
            return false;
        }

        if (Utils::isSerialized($ret, $ret)) {
            // Go through each file and make sure none of them have changed
            foreach ($ret['files'] as $file => $lastModified) {
                if (filemtime($file) > $lastModified) {
                    return false;
                }
            }

            $ret = serialize($ret);
        }

        return $ret;
    }
451373
public function needsRebuild($cacheFile)
    {
        $needsRebuild = true;

        if ($this->serializeCache->exists($cacheFile)) {
            try {
                $needsRebuild = time() - $this->ttl >= $this->serializeCache->mtime($cacheFile);
            } catch (\RuntimeException $e) {
            }
        }

        return $needsRebuild;
    }
948418
public static function LoadCache ($ini_path, $cache_file_path) {
		clearstatcache(false, $cache_file_path);
		clearstatcache(false, $ini_path);
		return file_exists($cache_file_path) && filemtime($cache_file_path) < filemtime($ini_path) ? include $cache_file_path : null;
	}
694647
public function fileCacheSet($key, $value, $cache_time = 86400)
    {
        if ($this->isSingle()) {
            FilecacheKit::add($key, $value, $cache_time);
        }
    }
984852
private function isCacheUpToDate()
    {
        if (!file_exists($this->cachedFile)) {
            return false;
        }

        $cacheTime = filemtime($this->cachedFile);
        $mTime     = $this->modificationTime();

        return $cacheTime == $mTime;
    }
635877
protected function tryToLoadFromCache( $cacheFile, $lastChange )
	{
		if( !file_exists( $cacheFile ) )
			return FALSE;

		$lastCache	= @filemtime( $cacheFile );
		if( $lastCache && $lastChange <= $lastCache )
		{
			$content	= file_get_contents( $cacheFile );
			$array		= @unserialize( $content );
			if( is_array( $array ) )
			{
				$this->pairs	= $array;
				return TRUE;
			}
		}
		return FALSE;
	}
111577
public function get(CacheableInterface $item)
    {
        $targetFile = $this->getTargetFile($item->getHashKey());

        $return = false;
        if (file_exists($targetFile)) {
            if ($item->getTtl() > 0 && ((filemtime($targetFile) + $item->getTtl()) < time())) {
                $this->remove($item);
            } else {
                $return = unserialize(file_get_contents($targetFile, false, null, strlen(self::STR_PREFIX)));
            }
        }

        return $return;
    }
555749
public static function startFromFileCache(string $cacheFile)
    {
        self::start(
                function() use($cacheFile)
                {
                    if (file_exists($cacheFile)) {
                        return unserialize(file_get_contents($cacheFile));
                    }

                    return [];
                },
                function(array $annotationData) use($cacheFile)
                {
                    file_put_contents($cacheFile, serialize($annotationData));
                }
        );
    }
12505
protected function _writeFile($content, $duration) {
		//$cacheTime = date('Y-m-d H:i:s', $timestamp);
		$now = time();
		if (!$duration) {
			$cacheTime = 0;
		} elseif (is_numeric($duration)) {
			$cacheTime = $now + $duration;
		} else {
			$cacheTime = strtotime($duration, $now);
		}

		$url = $this->request->here();
		$url = str_replace($this->request->base, '', $url);
		if ($url === '/') {
			$url = '_root';
		}

		$cache = $url;
		$prefix = Configure::read('Cache.prefix');
		if ($prefix) {
			$cache = $prefix . '_' . $url;
		}
		if ($url !== '_root') {
			$cache = Inflector::slug($cache);
		}
		if (empty($cache)) {
			return false;
		}

		$ext = $this->response->mapType($this->response->type());
		$content = $this->_compress($content, $ext);

		$cache = $cache . '.html';
		$content = '<!--cachetime:' . $cacheTime . ';ext:' . $ext . '-->' . $content;

		$folder = CACHE . 'views' . DS;
		if (Configure::read('debug') && !is_dir($folder)) {
			mkdir($folder, 0770, true);
		}
		$file = $folder . $cache;

		return file_put_contents($file, $content);
	}