You are here

protected function FilesystemCache::doFetch in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php \Doctrine\Common\Cache\FilesystemCache::doFetch()

Fetches an entry from the cache.

Parameters

string $id The id of the cache entry to fetch.:

Return value

mixed|boolean The cached data or FALSE, if no cache entry exists for the given id.

Overrides CacheProvider::doFetch

File

vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php, line 43

Class

FilesystemCache
Filesystem cache driver.

Namespace

Doctrine\Common\Cache

Code

protected function doFetch($id) {
  $data = '';
  $lifetime = -1;
  $filename = $this
    ->getFilename($id);
  if (!is_file($filename)) {
    return false;
  }
  $resource = fopen($filename, "r");
  if (false !== ($line = fgets($resource))) {
    $lifetime = (int) $line;
  }
  if ($lifetime !== 0 && $lifetime < time()) {
    fclose($resource);
    return false;
  }
  while (false !== ($line = fgets($resource))) {
    $data .= $line;
  }
  fclose($resource);
  return unserialize($data);
}