You are here

protected function ChainCache::doFetch in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/cache/lib/Doctrine/Common/Cache/ChainCache.php \Doctrine\Common\Cache\ChainCache::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/ChainCache.php, line 59

Class

ChainCache
Cache provider that allows to easily chain multiple cache providers

Namespace

Doctrine\Common\Cache

Code

protected function doFetch($id) {
  foreach ($this->cacheProviders as $key => $cacheProvider) {
    if ($cacheProvider
      ->doContains($id)) {
      $value = $cacheProvider
        ->doFetch($id);

      // We populate all the previous cache layers (that are assumed to be faster)
      for ($subKey = $key - 1; $subKey >= 0; $subKey--) {
        $this->cacheProviders[$subKey]
          ->doSave($id, $value);
      }
      return $value;
    }
  }
  return false;
}