Loading core/core.services.yml +1 −1 Original line number Diff line number Diff line Loading @@ -1133,7 +1133,7 @@ services: Drupal\Core\Routing\AdminContext: '@router.admin_context' router.route_provider: class: Drupal\Core\Routing\RouteProvider arguments: ['@database', '@state', '@path.current', '@cache.routes', '@path_processor_manager', '@cache_tags.invalidator', 'router', '@language_manager'] arguments: ['@database', '@state', '@path.current', '@cache.data', '@path_processor_manager', '@cache_tags.invalidator', '@cache.routes', 'router', '@language_manager'] tags: - { name: backend_overridable } Drupal\Core\Routing\RouteProviderInterface: '@router.route_provider' Loading core/lib/Drupal/Core/Routing/RouteProvider.php +24 −5 Original line number Diff line number Diff line Loading @@ -85,6 +85,13 @@ class RouteProvider implements CacheableRouteProviderInterface, PreloadableRoute */ protected $cacheTagInvalidator; /** * The chained fast cache backend. * * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $fastCache; /** * A path processor manager for resolving the system path. * Loading Loading @@ -131,22 +138,34 @@ class RouteProvider implements CacheableRouteProviderInterface, PreloadableRoute * The path processor. * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tag_invalidator * The cache tag invalidator. * @param \Drupal\Core\Cache\CacheBackendInterface $fast_cache * The chained fast cache backend. * @param string $table * (Optional) The table in the database to use for matching. Defaults to * 'router'. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * (Optional) The language manager. */ public function __construct(Connection $connection, StateInterface $state, CurrentPathStack $current_path, CacheBackendInterface $cache_backend, InboundPathProcessorInterface $path_processor, CacheTagsInvalidatorInterface $cache_tag_invalidator, $table = 'router', ?LanguageManagerInterface $language_manager = NULL) { public function __construct(Connection $connection, StateInterface $state, CurrentPathStack $current_path, CacheBackendInterface $cache_backend, InboundPathProcessorInterface $path_processor, CacheTagsInvalidatorInterface $cache_tag_invalidator, $fast_cache = NULL, $table = 'router', ?LanguageManagerInterface $language_manager = NULL) { $this->connection = $connection; $this->state = $state; $this->currentPath = $current_path; $this->cache = $cache_backend; $this->cacheTagInvalidator = $cache_tag_invalidator; $this->pathProcessor = $path_processor; if (!$fast_cache instanceof CacheBackendInterface) { @trigger_error('Calling ' . __METHOD__ . '() without the $fast_cache argument is deprecated in drupal:11.4.0 and the argument will be required in drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/3503843', E_USER_DEPRECATED); $this->fastCache = \Drupal::service('cache.routes'); $this->tableName = $fast_cache; $this->languageManager = $table ?: \Drupal::languageManager(); } else { $this->fastCache = $fast_cache; $this->tableName = $table; $this->languageManager = $language_manager ?: \Drupal::languageManager(); } } /** * Finds routes that may potentially match the request. Loading Loading @@ -245,7 +264,7 @@ public function preLoadRoutes($names) { $routes_to_load = array_diff($names, array_keys($this->routes)); if ($routes_to_load) { $cached = $this->cache->getMultiple($routes_to_load); $cached = $this->fastCache->getMultiple($routes_to_load); foreach ($cached as $cid => $item) { $this->routes[$cid] = $item->data; } Loading @@ -267,7 +286,7 @@ public function preLoadRoutes($names) { ]; } if ($items) { $this->cache->setMultiple($items); $this->fastCache->setMultiple($items); } } catch (\Exception) { Loading core/modules/jsonapi/tests/src/FunctionalJavascript/JsonApiPerformanceTest.php +7 −4 Original line number Diff line number Diff line Loading @@ -85,19 +85,21 @@ public function testGetIndividual(): void { 'CacheGetCount' => 41, 'CacheGetCountByBin' => [ 'config' => 7, 'routes' => 8, 'data' => 1, 'bootstrap' => 5, 'discovery' => 13, 'entity' => 2, 'default' => 4, 'dynamic_page_cache' => 1, 'routes' => 7, 'jsonapi_normalizations' => 1, ], 'CacheSetCount' => 16, 'CacheSetCountByBin' => [ 'routes' => 7, 'data' => 1, 'entity' => 1, 'default' => 3, 'routes' => 6, 'dynamic_page_cache' => 2, 'jsonapi_normalizations' => 2, 'bootstrap' => 1, Loading Loading @@ -143,7 +145,7 @@ public function testGetIndividual(): void { 'CacheGetCount' => 18, 'CacheGetCountByBin' => [ 'config' => 5, 'routes' => 1, 'data' => 1, 'discovery' => 5, 'bootstrap' => 3, 'entity' => 1, Loading Loading @@ -197,12 +199,13 @@ public function testGetIndividual(): void { 'CacheGetCount' => 42, 'CacheGetCountByBin' => [ 'config' => 7, 'routes' => 8, 'data' => 1, 'discovery' => 13, 'bootstrap' => 4, 'entity' => 2, 'default' => 4, 'dynamic_page_cache' => 2, 'routes' => 7, 'jsonapi_normalizations' => 2, ], 'CacheSetCount' => 3, Loading core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryAuthenticatedPerformanceTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -66,10 +66,10 @@ protected function doTestFrontPageAuthenticatedWarmCache(): void { 'config' => 12, 'bootstrap' => 7, 'discovery' => 5, 'routes' => 3, 'data' => 4, 'dynamic_page_cache' => 2, 'render' => 2, 'data' => 3, 'routes' => 2, ], 'CacheSetCount' => 0, 'CacheDeleteCount' => 0, Loading Loading @@ -133,12 +133,12 @@ protected function doTestNodePageAdministrator(): void { 'config' => 60, 'bootstrap' => 15, 'discovery' => 75, 'routes' => 22, 'data' => 13, 'entity' => 24, 'dynamic_page_cache' => 1, 'default' => 21, 'routes' => 18, 'render' => 18, 'data' => 9, 'menu' => 22, ], 'CacheSetCount' => 266, Loading core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -223,12 +223,12 @@ protected function testNodePageWarmCache(): void { 'config' => 34, 'bootstrap' => 12, 'discovery' => 67, 'routes' => 7, 'data' => 6, 'entity' => 21, 'dynamic_page_cache' => 1, 'routes' => 5, 'render' => 17, 'default' => 3, 'data' => 4, ], 'CacheSetCount' => 41, 'CacheDeleteCount' => 0, Loading Loading
core/core.services.yml +1 −1 Original line number Diff line number Diff line Loading @@ -1133,7 +1133,7 @@ services: Drupal\Core\Routing\AdminContext: '@router.admin_context' router.route_provider: class: Drupal\Core\Routing\RouteProvider arguments: ['@database', '@state', '@path.current', '@cache.routes', '@path_processor_manager', '@cache_tags.invalidator', 'router', '@language_manager'] arguments: ['@database', '@state', '@path.current', '@cache.data', '@path_processor_manager', '@cache_tags.invalidator', '@cache.routes', 'router', '@language_manager'] tags: - { name: backend_overridable } Drupal\Core\Routing\RouteProviderInterface: '@router.route_provider' Loading
core/lib/Drupal/Core/Routing/RouteProvider.php +24 −5 Original line number Diff line number Diff line Loading @@ -85,6 +85,13 @@ class RouteProvider implements CacheableRouteProviderInterface, PreloadableRoute */ protected $cacheTagInvalidator; /** * The chained fast cache backend. * * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $fastCache; /** * A path processor manager for resolving the system path. * Loading Loading @@ -131,22 +138,34 @@ class RouteProvider implements CacheableRouteProviderInterface, PreloadableRoute * The path processor. * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tag_invalidator * The cache tag invalidator. * @param \Drupal\Core\Cache\CacheBackendInterface $fast_cache * The chained fast cache backend. * @param string $table * (Optional) The table in the database to use for matching. Defaults to * 'router'. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * (Optional) The language manager. */ public function __construct(Connection $connection, StateInterface $state, CurrentPathStack $current_path, CacheBackendInterface $cache_backend, InboundPathProcessorInterface $path_processor, CacheTagsInvalidatorInterface $cache_tag_invalidator, $table = 'router', ?LanguageManagerInterface $language_manager = NULL) { public function __construct(Connection $connection, StateInterface $state, CurrentPathStack $current_path, CacheBackendInterface $cache_backend, InboundPathProcessorInterface $path_processor, CacheTagsInvalidatorInterface $cache_tag_invalidator, $fast_cache = NULL, $table = 'router', ?LanguageManagerInterface $language_manager = NULL) { $this->connection = $connection; $this->state = $state; $this->currentPath = $current_path; $this->cache = $cache_backend; $this->cacheTagInvalidator = $cache_tag_invalidator; $this->pathProcessor = $path_processor; if (!$fast_cache instanceof CacheBackendInterface) { @trigger_error('Calling ' . __METHOD__ . '() without the $fast_cache argument is deprecated in drupal:11.4.0 and the argument will be required in drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/3503843', E_USER_DEPRECATED); $this->fastCache = \Drupal::service('cache.routes'); $this->tableName = $fast_cache; $this->languageManager = $table ?: \Drupal::languageManager(); } else { $this->fastCache = $fast_cache; $this->tableName = $table; $this->languageManager = $language_manager ?: \Drupal::languageManager(); } } /** * Finds routes that may potentially match the request. Loading Loading @@ -245,7 +264,7 @@ public function preLoadRoutes($names) { $routes_to_load = array_diff($names, array_keys($this->routes)); if ($routes_to_load) { $cached = $this->cache->getMultiple($routes_to_load); $cached = $this->fastCache->getMultiple($routes_to_load); foreach ($cached as $cid => $item) { $this->routes[$cid] = $item->data; } Loading @@ -267,7 +286,7 @@ public function preLoadRoutes($names) { ]; } if ($items) { $this->cache->setMultiple($items); $this->fastCache->setMultiple($items); } } catch (\Exception) { Loading
core/modules/jsonapi/tests/src/FunctionalJavascript/JsonApiPerformanceTest.php +7 −4 Original line number Diff line number Diff line Loading @@ -85,19 +85,21 @@ public function testGetIndividual(): void { 'CacheGetCount' => 41, 'CacheGetCountByBin' => [ 'config' => 7, 'routes' => 8, 'data' => 1, 'bootstrap' => 5, 'discovery' => 13, 'entity' => 2, 'default' => 4, 'dynamic_page_cache' => 1, 'routes' => 7, 'jsonapi_normalizations' => 1, ], 'CacheSetCount' => 16, 'CacheSetCountByBin' => [ 'routes' => 7, 'data' => 1, 'entity' => 1, 'default' => 3, 'routes' => 6, 'dynamic_page_cache' => 2, 'jsonapi_normalizations' => 2, 'bootstrap' => 1, Loading Loading @@ -143,7 +145,7 @@ public function testGetIndividual(): void { 'CacheGetCount' => 18, 'CacheGetCountByBin' => [ 'config' => 5, 'routes' => 1, 'data' => 1, 'discovery' => 5, 'bootstrap' => 3, 'entity' => 1, Loading Loading @@ -197,12 +199,13 @@ public function testGetIndividual(): void { 'CacheGetCount' => 42, 'CacheGetCountByBin' => [ 'config' => 7, 'routes' => 8, 'data' => 1, 'discovery' => 13, 'bootstrap' => 4, 'entity' => 2, 'default' => 4, 'dynamic_page_cache' => 2, 'routes' => 7, 'jsonapi_normalizations' => 2, ], 'CacheSetCount' => 3, Loading
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryAuthenticatedPerformanceTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -66,10 +66,10 @@ protected function doTestFrontPageAuthenticatedWarmCache(): void { 'config' => 12, 'bootstrap' => 7, 'discovery' => 5, 'routes' => 3, 'data' => 4, 'dynamic_page_cache' => 2, 'render' => 2, 'data' => 3, 'routes' => 2, ], 'CacheSetCount' => 0, 'CacheDeleteCount' => 0, Loading Loading @@ -133,12 +133,12 @@ protected function doTestNodePageAdministrator(): void { 'config' => 60, 'bootstrap' => 15, 'discovery' => 75, 'routes' => 22, 'data' => 13, 'entity' => 24, 'dynamic_page_cache' => 1, 'default' => 21, 'routes' => 18, 'render' => 18, 'data' => 9, 'menu' => 22, ], 'CacheSetCount' => 266, Loading
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -223,12 +223,12 @@ protected function testNodePageWarmCache(): void { 'config' => 34, 'bootstrap' => 12, 'discovery' => 67, 'routes' => 7, 'data' => 6, 'entity' => 21, 'dynamic_page_cache' => 1, 'routes' => 5, 'render' => 17, 'default' => 3, 'data' => 4, ], 'CacheSetCount' => 41, 'CacheDeleteCount' => 0, Loading