function CacheTagPreloadSubscriber::onRequest

Preloads frequently used cache tags.

Parameters

\Symfony\Component\HttpKernel\Event\RequestEvent $event: The request event.

File

core/lib/Drupal/Core/Cache/EventSubscriber/CacheTagPreloadSubscriber.php, line 26

Class

CacheTagPreloadSubscriber
Preloads frequently used cache tags.

Namespace

Drupal\Core\Cache\EventSubscriber

Code

public function onRequest(RequestEvent $event) : void {
  if ($event->isMainRequest() && $this->cacheTagsChecksum instanceof CacheTagsChecksumPreloadInterface) {
    $default_preload_cache_tags = array_merge([
      'route_match',
      'access_policies',
      'routes',
      'router',
      'entity_types',
      'entity_field_info',
      'entity_bundles',
      'local_task',
      'library_info',
    ], Settings::get('cache_preload_tags', []));
    $this->cacheTagsChecksum
      ->registerCacheTagsForPreload($default_preload_cache_tags);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.