Check whether a cache file exists and is not expired.

@return bool
768963
public function cacheExists()
    {
        $cacheFile = $this->getCacheFile();
        if (file_exists($cacheFile) && filemtime($cacheFile) > (time()-$this->cachePeriod)) {
            return(true);
        } else {
            return(false);
        }
    }
358852
public function isAvailable()
    {
        return \file_exists($this->cacheDir) && \is_dir($this->cacheDir) && \is_writable($this->cacheDir);
    }
1349234
public function isExpired()
    {
        if (!FS::isFile($this->_resultFile)) {
            return true;
        }

        $fileAge = abs(time() - filemtime($this->_resultFile));
        if ($fileAge >= $this->_cache_ttl) {
            return true;
        }

        $firstLine = trim(FS::firstLine($this->_resultFile));
        $expected  = trim($this->_getHeader());
        if ($expected === $firstLine) {
            return false;
        }

        return true;
    }
1083867
public function existsFile() {
		$file =$this->getPath();
		if (file_exists($file)) {
			if ($this->type == self::TYPE_ENTITY) {
				return self::FILE_MATCH;
			}
			
			$data = file_get_contents($file);
			if (strpos($data, "@version ".Version::BUILDER_VERSION) !== FALSE) {
				return self::FILE_MATCH;
			} else {
				return self::FILE_OUTDATED;
			}
		}
		return self::FILE_MISSING;
	}
334812
private function _isCached() 
    {
        $filters = false;

        if ($this->cacheSettings) {
        
            if ($this->cache) {
                $filters = $this->cache->getCache();
            }
        }

        return $filters;
    }
261408
protected function loadFromCache()
    {
        $this->log->debug("Load from cache file {$this->filePath}");
        $data = $this->getDataFromFile();
        if ($data === false) {
            $data = '';
        }

        // validate data through parser
        if (!$this->isDataValid($data)) {
            $this->addError($this->filePath, 'Data not valid according to parser');

            return false;
        }

        // verify if local cache is expired
        if ($this->isCacheExpired()) {
            $this->addError($this->filePath, 'Local cache is expired');

            return false;
        }

        return true;
    }
780213
public function isExpired($key)
    {
        // Check to see if the cached data has expired.
        if (filemtime($this->fetchStreamUri($key)) < (time() - $this->ttl)) {
            return true;
        }

        return false;
    }
642599
public function isSaved( string $name ): bool
	{
		if (realpath($this->cacheDir . DIRECTORY_SEPARATOR . $name) == false)
			return false;

		/** @var FileCacheStorage $storage */
		$storage = $this->load($name, true);
		return $storage->expires_at > time();
	}
678610
protected function isSaved(): bool
    {
        return $this->filesystem->has($this->path)
            && $this->filesystem->getTimestamp($this->path) > $this->file->getUpdatedAt();
    }
81468
public function has(string $key): bool
    {
        $file = $this->cacheFile($key);

        if (is_file($file)) {
            $data = include $file;
            $expire = (int)$data['ttl'];
            return $expire === 0 || time() < $expire;
        }

        return false;
    }
225623
public function compiledExists()
    {
        return $this->cached === false ? false : file_exists($this->cachePath.'/'.$this->getClassName().'.php');
    }
1203424
public function isCached($key)
    {
        if ($cachedData = $this->loadCache()) {
            if (isset($cachedData[$key])) {
                if (!$this->isExpired($cachedData[$key]['time'], $cachedData[$key]['expire'])) {
                    return true;
                }
            }
        }
        return false; // If cache file doesn't exist or cache is empty or key doesn't exist in array, key isn't cached
    }
890960
public function exists(Memento\Key $key, $expired = false)
    {
        $keyPath = $this->getKeyPath($key);

        $cacheFile = $keyPath . DIRECTORY_SEPARATOR . self::FILENAME_CACHE;

        return file_exists($cacheFile);
    }
355547
public function isExpired()
    {
        $ret = true;

        $now = new \DateTime();
        if ($this->expirationDate > $now) {
            $ret = false;
        }

        return $ret;
    }
199694
public function has(string $key): bool
    {
        $file = $this->cacheFile($key);

        if (is_file($file)) {
            $handle = fopen($file, 'r');
            $expire = (int)trim(fgets($handle));
            fclose($handle);
            return $expire === 0 || time() < $expire;
        }

        return false;
    }
634785
public function isCached() {
		if ($this->cached) return true;

		// Passed a cacheId?
		if (!$this->cacheId) return false;

		// Cache file exists?
		if (!file_exists($this->cachePath . $this->cacheId)) return false;

		// Can get the time of the file?
		if (!($mtime = filemtime($this->cachePath . $this->cacheId))) return false;

		// Cache expired?
		if (($mtime + $this->expire) < time()) {
			unlink($this->cachePath . $this->cacheId);
			return false;
		} else {
			/**
			 * Cache the results of this isCached() call.  Why?  So
			 * we don't have to double the overhead for each template.
			 * If we didn't cache, it would be hitting the file system
			 * twice as much (file_exists() & filemtime() [twice each]).
			 */
			$this->cached = true;
			return true;
		}
	}
684260
protected function isExpired()
    {
        if (! $this->filesystem->exists($this->cached)) {
            return true;
        }

        $lastModified = $this->filesystem->lastModified($this->file->getPath());

        return $lastModified >= $this->filesystem->lastModified($this->cached);
    }