public function AliasManagerCacheDecorator::writeCache

Implements \Drupal\Core\CacheDecorator\CacheDecoratorInterface::writeCache().

Cache an array of the system paths available on each page. We assume that aliases will be needed for the majority of these paths during subsequent requests, and load them in a single query during path alias lookup.

Overrides CacheDecoratorInterface::writeCache

File

drupal/core/lib/Drupal/Core/CacheDecorator/AliasManagerCacheDecorator.php, line 72
Contains Drupal\Core\CacheDecorator\AliasManagerCacheDecorator.

Class

AliasManagerCacheDecorator
Class used by the PathSubscriber to get the system path and cache path lookups.

Namespace

Drupal\Core\CacheDecorator

Code

public function writeCache() {
  $path_lookups = $this
    ->getPathLookups();

  // Check if the system paths for this page were loaded from cache in this
  // request to avoid writing to cache on every request.
  if ($this->cacheNeedsWriting && !empty($path_lookups) && !empty($this->cacheKey)) {

    // Set the path cache to expire in 24 hours.
    $expire = REQUEST_TIME + 60 * 60 * 24;
    $this->cache
      ->set($this->cacheKey, $path_lookups, $expire);
  }
}