diff --git a/core/core.services.yml b/core/core.services.yml index afb710b..ab708ad 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -36,27 +36,13 @@ services: factory_method: get factory_service: cache_factory arguments: [entity] - cache.field: + cache.render: class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } factory_method: get factory_service: cache_factory - arguments: [field] - cache.menu: - class: Drupal\Core\Cache\CacheBackendInterface - tags: - - { name: cache.bin } - factory_method: get - factory_service: cache_factory - arguments: [menu] - cache.page: - class: Drupal\Core\Cache\CacheBackendInterface - tags: - - { name: cache.bin } - factory_method: get - factory_service: cache_factory - arguments: [page] + arguments: [render] cache.path: class: Drupal\Core\Cache\CacheBackendInterface tags: @@ -194,13 +180,13 @@ services: arguments: ['@entity.manager', '@form_builder'] plugin.manager.field.field_type: class: Drupal\Core\Field\FieldTypePluginManager - arguments: ['@container.namespaces', '@cache.field', '@language_manager', '@module_handler'] + arguments: ['@container.namespaces', '@cache.entity', '@language_manager', '@module_handler'] plugin.manager.field.widget: class: Drupal\Core\Field\WidgetPluginManager - arguments: ['@container.namespaces', '@cache.field', '@module_handler', '@language_manager', '@plugin.manager.field.field_type'] + arguments: ['@container.namespaces', '@cache.entity', '@module_handler', '@language_manager', '@plugin.manager.field.field_type'] plugin.manager.field.formatter: class: Drupal\Core\Field\FormatterPluginManager - arguments: ['@container.namespaces', '@cache.field', '@module_handler', '@language_manager', '@plugin.manager.field.field_type'] + arguments: ['@container.namespaces', '@cache.entity', '@module_handler', '@language_manager', '@plugin.manager.field.field_type'] plugin.manager.archiver: class: Drupal\Core\Archiver\ArchiverManager parent: default_plugin_manager diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 4d90140..180f7f8 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -789,7 +789,7 @@ function drupal_page_cache_get_cid(Request $request) { */ function drupal_page_get_cache(Request $request) { if (drupal_page_is_cacheable()) { - return \Drupal::cache('page')->get(drupal_page_cache_get_cid($request)); + return \Drupal::cache('render')->get(drupal_page_cache_get_cid($request)); } } diff --git a/core/includes/common.inc b/core/includes/common.inc index 1f2b74b..ffc4c27 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3292,7 +3292,7 @@ function drupal_page_set_cache(Response $response, Request $request) { if ($page_compressed) { $cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP); } - \Drupal::cache('page')->set($cache->cid, $cache->data, $cache->expire, $cache->tags); + \Drupal::cache('render')->set($cache->cid, $cache->data, $cache->expire, $cache->tags); } return $cache; } @@ -4945,9 +4945,7 @@ function drupal_flush_all_caches() { // sufficient, since new extensions cannot have any primed caches yet. $module_handler->invokeAll('cache_flush'); foreach (Cache::getBins() as $service_id => $cache_backend) { - if ($service_id != 'cache.menu') { - $cache_backend->deleteAll(); - } + $cache_backend->deleteAll(); } // Flush asset file caches. diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 60121f7..ca7227c 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -388,7 +388,7 @@ function install_begin_request(&$install_state) { // Register the translation services. install_register_translation_service($container); - foreach (array('bootstrap', 'config', 'cache', 'menu', 'page', 'path') as $bin) { + foreach (array('bootstrap', 'config', 'cache', 'entity', 'render', 'path') as $bin) { $container ->register("cache.$bin", 'Drupal\Core\Cache\MemoryBackend') ->addArgument($bin); diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 495fb47..2d02244 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1017,8 +1017,8 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { $cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $language_interface->id . ':' . (int) $max_depth; if (!isset($tree[$cid])) { - // If the static variable doesn't have the data, check {cache_menu}. - $cache = \Drupal::cache('menu')->get($cid); + // If the static variable doesn't have the data, check {cache_path}. + $cache = \Drupal::cache('path')->get($cid); if ($cache && isset($cache->data)) { // If the cache entry exists, it contains the parameters for // menu_build_tree(). @@ -1045,7 +1045,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { } // Cache the tree building parameters using the page-specific cid. - \Drupal::cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name)); + \Drupal::cache('path')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name)); } // Build the tree using the parameters; the resulting tree will be cached @@ -1152,8 +1152,8 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = } if (!isset($tree[$cid])) { - // If the static variable doesn't have the data, check {cache_menu}. - $cache = \Drupal::cache('menu')->get($cid); + // If the static variable doesn't have the data, check {cache_path}. + $cache = \Drupal::cache('path')->get($cid); if ($cache && isset($cache->data)) { // If the cache entry exists, it contains the parameters for // menu_build_tree(). @@ -1221,7 +1221,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = $tree_parameters['active_trail'] = $active_trail; } // Cache the tree building parameters using the page-specific cid. - \Drupal::cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name)); + \Drupal::cache('path')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name)); } // Build the tree using the parameters; the resulting tree will be cached @@ -1287,9 +1287,9 @@ function _menu_build_tree($menu_name, array $parameters = array()) { } $tree_cid = 'links:' . $menu_name . ':tree-data:' . $language_interface->id . ':' . hash('sha256', serialize($parameters)); - // If we do not have this tree in the static cache, check {cache_menu}. + // If we do not have this tree in the static cache, check {cache_path}. if (!isset($trees[$tree_cid])) { - $cache = \Drupal::cache('menu')->get($tree_cid); + $cache = \Drupal::cache('path')->get($tree_cid); if ($cache && isset($cache->data)) { $trees[$tree_cid] = $cache->data; } @@ -1332,7 +1332,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) { menu_tree_collect_node_links($data['tree'], $data['node_links']); // Cache the data, if it is not already in the cache. - \Drupal::cache('menu')->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name)); + \Drupal::cache('path')->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name)); $trees[$tree_cid] = $data; } @@ -2111,7 +2111,7 @@ function menu_get_active_trail() { * might have been made to the router items or menu links. */ function menu_cache_clear_all() { - \Drupal::cache('menu')->deleteAll(); + \Drupal::cache('path')->deleteAll(); menu_reset_static_cache(); } diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php index 3bdbc64..6b46cb0 100644 --- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php @@ -18,9 +18,9 @@ * set a variable with the name of the cache bin as its key and the name of * your class as its value. For example, if your implementation of * Drupal\Core\Cache\CacheBackendInterface was called MyCustomCache, the - * following line would make Drupal use it for the 'cache_page' bin: + * following line would make Drupal use it for the 'cache_render' bin: * @code - * $settings['cache_classes']['cache_page'] = 'MyCustomCache'; + * $settings['cache_classes']['cache_render'] = 'MyCustomCache'; * @endcode * * Additionally, you can register your cache implementation to be used by diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index cd81acc..7d59681 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -224,7 +224,7 @@ public function deleteMultiple(array $cids) { catch (\Exception $e) { // Create the cache table, which will be empty. This fixes cases during // core install where a cache table is cleared before it is set - // with {cache_block} and {cache_menu}. + // with {cache_render} and {cache_path}. if (!$this->ensureBinExists()) { $this->catchException($e); } @@ -267,7 +267,7 @@ public function deleteAll() { catch (\Exception $e) { // Create the cache table, which will be empty. This fixes cases during // core install where a cache table is cleared before it is set - // with {cache_block} and {cache_menu}. + // with {cache_render} and {cache_path}. if (!$this->ensureBinExists()) { $this->catchException($e); } diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php index ec468b7..453a366 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php @@ -134,7 +134,7 @@ protected function loadFieldItems(array $entities) { foreach ($entities as $id => $entity) { $cids[] = "field:{$this->entityTypeId}:$id"; } - $cache = \Drupal::cache('field')->getMultiple($cids); + $cache = \Drupal::cache('entity')->getMultiple($cids); // Put the cached field values back into the entities and remove them from // the list of entities to query. foreach ($entities as $id => $entity) { @@ -183,7 +183,7 @@ protected function loadFieldItems(array $entities) { } } $cid = "field:{$this->entityTypeId}:$id"; - \Drupal::cache('field')->set($cid, $data); + \Drupal::cache('entity')->set($cid, $data); } } } @@ -207,7 +207,7 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) { if ($update) { $entity_type = $entity->getEntityType(); if ($entity_type->isFieldDataCacheable()) { - \Drupal::cache('field')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id()); + \Drupal::cache('entity')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id()); } } } @@ -227,7 +227,7 @@ protected function deleteFieldItems(EntityInterface $entity) { $entity_type = $entity->getEntityType(); if ($entity_type->isFieldDataCacheable()) { - \Drupal::cache('field')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id()); + \Drupal::cache('entity')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id()); } } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index e97852c..002980c 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -211,7 +211,7 @@ function _block_get_renderable_region($list = array()) { '#cache' => array( 'keys' => array($key, $settings['module']), 'granularity' => $settings['cache'], - 'bin' => 'block', + 'bin' => 'render', 'tags' => array('content' => TRUE), ), ); diff --git a/core/modules/block/block.services.yml b/core/modules/block/block.services.yml index 34293d9..49af23d 100644 --- a/core/modules/block/block.services.yml +++ b/core/modules/block/block.services.yml @@ -1,14 +1,7 @@ services: plugin.manager.block: class: Drupal\block\Plugin\Type\BlockManager - arguments: ['@container.namespaces', '@cache.block', '@language_manager', '@module_handler', '@string_translation'] - cache.block: - class: Drupal\Core\Cache\CacheBackendInterface - tags: - - { name: cache.bin } - factory_method: get - factory_service: cache_factory - arguments: [block] + arguments: ['@container.namespaces', '@cache.render', '@language_manager', '@module_handler', '@string_translation'] theme.negotiator.block.admin_demo: class: Drupal\block\Theme\AdminDemoNegotiator tags: diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 601717b..673de85 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -561,8 +561,8 @@ public function bookTreeAllData($menu_name, $link = NULL, $max_depth = NULL) { $cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $language_interface->id . ':' . (int) $max_depth; if (!isset($tree[$cid])) { - // If the static variable doesn't have the data, check {cache_menu}. - $cache = \Drupal::cache('menu')->get($cid); + // If the static variable doesn't have the data, check {cache_path}. + $cache = \Drupal::cache('path')->get($cid); if ($cache && isset($cache->data)) { // If the cache entry exists, it contains the parameters for // menu_build_tree(). @@ -589,7 +589,7 @@ public function bookTreeAllData($menu_name, $link = NULL, $max_depth = NULL) { } // Cache the tree building parameters using the page-specific cid. - \Drupal::cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name)); + \Drupal::cache('path')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name)); } // Build the tree using the parameters; the resulting tree will be cached @@ -731,9 +731,9 @@ protected function _menu_build_tree($menu_name, array $parameters = array()) { } $tree_cid = 'links:' . $menu_name . ':tree-data:' . $language_interface->id . ':' . hash('sha256', serialize($parameters)); - // If we do not have this tree in the static cache, check {cache_menu}. + // If we do not have this tree in the static cache, check {cache_path}. if (!isset($trees[$tree_cid])) { - $cache = \Drupal::cache('menu')->get($tree_cid); + $cache = \Drupal::cache('path')->get($tree_cid); if ($cache && isset($cache->data)) { $trees[$tree_cid] = $cache->data; } @@ -776,7 +776,7 @@ protected function _menu_build_tree($menu_name, array $parameters = array()) { $this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']); // Cache the data, if it is not already in the cache. - \Drupal::cache('menu')->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name)); + \Drupal::cache('path')->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name)); $trees[$tree_cid] = $data; } @@ -993,12 +993,12 @@ public function bookMenuSubtreeData($link) { $cid = 'links:' . $link['menu_name'] . ':subtree-cid:' . $link['mlid']; if (!isset($tree[$cid])) { - $cache = \Drupal::cache('menu')->get($cid); + $cache = \Drupal::cache('path')->get($cid); if ($cache && isset($cache->data)) { // If the cache entry exists, it will just be the cid for the actual data. // This avoids duplication of large amounts of data. - $cache = \Drupal::cache('menu')->get($cache->data); + $cache = \Drupal::cache('path')->get($cache->data); if ($cache && isset($cache->data)) { $data = $cache->data; @@ -1029,11 +1029,11 @@ public function bookMenuSubtreeData($link) { $tree_cid = 'links:' . $item['menu_name'] . ':subtree-data:' . hash('sha256', serialize($data)); // Cache the data, if it is not already in the cache. - if (!\Drupal::cache('menu')->get($tree_cid)) { - \Drupal::cache('menu')->set($tree_cid, $data); + if (!\Drupal::cache('path')->get($tree_cid)) { + \Drupal::cache('path')->set($tree_cid, $data); } // Cache the cid of the (shared) data using the menu and item-specific cid. - \Drupal::cache('menu')->set($cid, $tree_cid); + \Drupal::cache('path')->set($cid, $tree_cid); } // Check access for the current user to each item in the tree. $this->bookTreeCheckAccess($data['tree'], $data['node_links']); diff --git a/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php index 07beef0..9006926 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php @@ -63,7 +63,7 @@ public function __construct(CacheBackendInterface $cache, EntityStorageControlle public static function create(ContainerInterface $container) { $entity_manager = $container->get('entity.manager'); return new static( - $container->get('cache.menu'), + $container->get('cache.path'), $entity_manager->getStorageController('node'), $entity_manager->getStorageController('menu_link') ); diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php index 319e168..72dcdc2 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php @@ -149,9 +149,7 @@ public function submitForm(array &$form, array &$form_state) { // Flush all persistent caches. $this->moduleHandler->invokeAll('cache_flush'); foreach (Cache::getBins() as $service_id => $cache_backend) { - if ($service_id != 'cache.menu') { - $cache_backend->deleteAll(); - } + $cache_backend->deleteAll(); } drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->name))); diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 6bd2c6d..dc0968e 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -289,7 +289,7 @@ function field_modules_uninstalled($modules) { * Clears the field info and field data caches. */ function field_cache_clear() { - \Drupal::cache('field')->deleteAll(); + \Drupal::cache('entity')->deleteAll(); field_info_cache_clear(); } diff --git a/core/modules/field/field.services.yml b/core/modules/field/field.services.yml index 43d3d1b..f2bd3ce 100644 --- a/core/modules/field/field.services.yml +++ b/core/modules/field/field.services.yml @@ -1,5 +1,5 @@ services: field.info: class: Drupal\field\FieldInfo - arguments: ['@cache.field', '@config.factory', '@module_handler', '@plugin.manager.field.field_type', '@language_manager'] + arguments: ['@cache.entity', '@config.factory', '@module_handler', '@plugin.manager.field.field_type', '@language_manager'] diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index 9428dc0..975cd45 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -187,14 +187,14 @@ function testFieldAttachCache() { $cid = "field:$entity_type:" . $entity_init->id(); // Check that no initial cache entry is present. - $this->assertFalse(\Drupal::cache('field')->get($cid), 'Non-cached: no initial cache entry'); + $this->assertFalse(\Drupal::cache('entity')->get($cid), 'Non-cached: no initial cache entry'); // Save, and check that no cache entry is present. $entity = clone($entity_init); $entity->{$this->field_name}->setValue($values); $entity = $this->entitySaveReload($entity); $cid = "field:$entity_type:" . $entity->id(); - $this->assertFalse(\Drupal::cache('field')->get($cid), 'Non-cached: no cache entry on insert and load'); + $this->assertFalse(\Drupal::cache('entity')->get($cid), 'Non-cached: no cache entry on insert and load'); // Cacheable entity type. $entity_type = 'entity_test_cache'; @@ -207,7 +207,7 @@ function testFieldAttachCache() { // Check that no initial cache entry is present. $cid = "field:$entity_type:" . $entity->id(); - $this->assertFalse(\Drupal::cache('field')->get($cid), 'Cached: no initial cache entry'); + $this->assertFalse(\Drupal::cache('entity')->get($cid), 'Cached: no initial cache entry'); // Save, and check that no cache entry is present. $entity = clone($entity_init); @@ -215,12 +215,12 @@ function testFieldAttachCache() { $entity->save(); $cid = "field:$entity_type:" . $entity->id(); - $this->assertFalse(\Drupal::cache('field')->get($cid), 'Cached: no cache entry on insert'); + $this->assertFalse(\Drupal::cache('entity')->get($cid), 'Cached: no cache entry on insert'); // Load, and check that a cache entry is present with the expected values. $controller = $this->container->get('entity.manager')->getStorageController($entity->getEntityTypeId()); $controller->resetCache(); $controller->load($entity->id()); - $cache = \Drupal::cache('field')->get($cid); + $cache = \Drupal::cache('entity')->get($cid); $this->assertEqual($cache->data[$langcode][$this->field_name_2], $values, 'Cached: correct cache entry on load'); // Update with different values, and check that the cache entry is wiped. @@ -231,12 +231,12 @@ function testFieldAttachCache() { )); $entity->{$this->field_name_2} = $values; $entity->save(); - $this->assertFalse(\Drupal::cache('field')->get($cid), 'Cached: no cache entry on update'); + $this->assertFalse(\Drupal::cache('entity')->get($cid), 'Cached: no cache entry on update'); // Load, and check that a cache entry is present with the expected values. $controller->resetCache(); $controller->load($entity->id()); - $cache = \Drupal::cache('field')->get($cid); + $cache = \Drupal::cache('entity')->get($cid); $this->assertEqual($cache->data[$langcode][$this->field_name_2], $values, 'Cached: correct cache entry on load'); // Create a new revision, and check that the cache entry is wiped. @@ -248,17 +248,17 @@ function testFieldAttachCache() { $entity->{$this->field_name_2} = $values; $entity->setNewRevision(); $entity->save(); - $this->assertFalse(\Drupal::cache('field')->get($cid), 'Cached: no cache entry on new revision creation'); + $this->assertFalse(\Drupal::cache('entity')->get($cid), 'Cached: no cache entry on new revision creation'); // Load, and check that a cache entry is present with the expected values. $controller->resetCache(); $controller->load($entity->id()); - $cache = \Drupal::cache('field')->get($cid); + $cache = \Drupal::cache('entity')->get($cid); $this->assertEqual($cache->data[$langcode][$this->field_name_2], $values, 'Cached: correct cache entry on load'); // Delete, and check that the cache entry is wiped. $entity->delete(); - $this->assertFalse(\Drupal::cache('field')->get($cid), 'Cached: no cache entry after delete'); + $this->assertFalse(\Drupal::cache('entity')->get($cid), 'Cached: no cache entry after delete'); } /** diff --git a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php index 6e5babd..70d97eb 100644 --- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php @@ -267,11 +267,8 @@ public function flush($path = NULL) { field_info_cache_clear(); drupal_theme_rebuild(); - // Clear page caches when flushing. - if ($module_handler->moduleExists('block')) { - \Drupal::cache('block')->deleteAll(); - } - \Drupal::cache('page')->deleteAll(); + \Drupal::cache('render')->deleteAll(); + return $this; } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 105f44e..fea4182 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -245,7 +245,7 @@ function locale_stream_wrappers() { function locale_language_insert($language) { // @todo move these two cache clears out. See http://drupal.org/node/1293252 // Changing the language settings impacts the interface. - \Drupal::cache('page')->deleteAll(); + \Drupal::cache('render')->deleteAll(); // Force JavaScript translation file re-creation for the new language. _locale_invalidate_js($language->id); } @@ -256,7 +256,7 @@ function locale_language_insert($language) { function locale_language_update($language) { // @todo move these two cache clears out. See http://drupal.org/node/1293252 // Changing the language settings impacts the interface. - \Drupal::cache('page')->deleteAll(); + \Drupal::cache('render')->deleteAll(); // Force JavaScript translation file re-creation for the modified language. _locale_invalidate_js($language->id); } @@ -277,7 +277,7 @@ function locale_language_delete($language) { // Changing the language settings impacts the interface: _locale_invalidate_js($language->id); - \Drupal::cache('page')->deleteAll(); + \Drupal::cache('render')->deleteAll(); // Clear locale translation caches. locale_translation_status_delete_languages(array($language->id)); diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index d926528..d36b9d1 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -514,7 +514,7 @@ public function testMenuBlockPageCacheTags() { $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); $cid_parts = array(url('test-page', array('absolute' => TRUE)), 'html'); $cid = sha1(implode(':', $cid_parts)); - $cache_entry = \Drupal::cache('page')->get($cid); + $cache_entry = \Drupal::cache('render')->get($cid); $this->assertIdentical($cache_entry->tags, array('content:1', 'menu:llama')); // The "Llama" menu is modified. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodePageCacheTest.php b/core/modules/node/lib/Drupal/node/Tests/NodePageCacheTest.php index 49bc190..de69684 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodePageCacheTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodePageCacheTest.php @@ -57,7 +57,7 @@ public function testNodeDelete() { // Verify the presence of the correct cache tags. $cid_parts = array(url($node_path, array('absolute' => TRUE)), 'html'); $cid = sha1(implode(':', $cid_parts)); - $cache_entry = \Drupal::cache('page')->get($cid); + $cache_entry = \Drupal::cache('render')->get($cid); $this->assertIdentical($cache_entry->tags, array('content:1', 'user:' . $author->id(), 'filter_format:plain_text')); // Login and delete the node. diff --git a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php index 3f44128..1fa7cb5 100644 --- a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php +++ b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php @@ -22,19 +22,19 @@ class PerformanceForm extends ConfigFormBase { * * @var \Drupal\Core\Cache\CacheBackendInterface */ - protected $pageCache; + protected $renderCache; /** * Constructs a PerformanceForm object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The factory for configuration objects. - * @param \Drupal\Core\Cache\CacheBackendInterface $page_cache + * @param \Drupal\Core\Cache\CacheBackendInterface $render_cache */ - public function __construct(ConfigFactoryInterface $config_factory, CacheBackendInterface $page_cache) { + public function __construct(ConfigFactoryInterface $config_factory, CacheBackendInterface $render_cache) { parent::__construct($config_factory); - $this->pageCache = $page_cache; + $this->renderCache = $render_cache; } /** @@ -43,7 +43,7 @@ public function __construct(ConfigFactoryInterface $config_factory, CacheBackend public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), - $container->get('cache.page') + $container->get('cache.render') ); } @@ -143,7 +143,7 @@ public function submitForm(array &$form, array &$form_state) { drupal_clear_js_cache(); // This form allows page compression settings to be changed, which can // invalidate the page cache, so it needs to be cleared on form submit. - $this->pageCache->deleteAll(); + $this->renderCache->deleteAll(); $this->configFactory->get('system.performance') ->set('cache.page.use_internal', $form_state['values']['cache']) diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php index 3ca1f19..8021cd9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php @@ -64,7 +64,7 @@ function testPageCacheTags() { $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); $cid_parts = array(url($path, array('absolute' => TRUE)), 'html'); $cid = sha1(implode(':', $cid_parts)); - $cache_entry = \Drupal::cache('page')->get($cid); + $cache_entry = \Drupal::cache('render')->get($cid); $this->assertIdentical($cache_entry->tags, array('content:1', 'system_test_cache_tags_page:1')); Cache::invalidateTags($tags); diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php index ec1107c..97821a7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php @@ -36,7 +36,7 @@ function testFlushAllCaches() { // Create cache entries for each flushed cache bin. $bins = Cache::getBins(); $this->assertTrue($bins, 'cache_get_bins() returned bins to flush.'); - $bins['menu'] = $this->container->get('cache.menu'); + $bins['path'] = $this->container->get('cache.path'); foreach ($bins as $bin => $cache_backend) { $cid = 'test_cid_clear' . $bin; $cache_backend->set($cid, $this->default_value); diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/DatabaseBackendTagTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/DatabaseBackendTagTest.php index 1645779..2afb39a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/DatabaseBackendTagTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/DatabaseBackendTagTest.php @@ -47,7 +47,7 @@ public function containerBuild(ContainerBuilder $container) { public function testTagInvalidations() { // Create cache entry in multiple bins. $tags = array('test_tag' => array(1, 2, 3)); - $bins = array('path', 'bootstrap', 'page'); + $bins = array('path', 'bootstrap', 'render'); foreach ($bins as $bin) { $bin = \Drupal::cache($bin); $bin->set('test', 'value', Cache::PERMANENT, $tags); @@ -71,7 +71,7 @@ public function testTagInvalidations() { public function testTagDeletetions() { // Create cache entry in multiple bins. $tags = array('test_tag' => array(1, 2, 3)); - $bins = array('path', 'bootstrap', 'page'); + $bins = array('path', 'bootstrap', 'render'); foreach ($bins as $bin) { $bin = \Drupal::cache($bin); $bin->set('test', 'value', Cache::PERMANENT, $tags); diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php index 4b4c799..8440df9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php @@ -98,7 +98,7 @@ protected function verifyPageCacheTags($path, $expected_tags) { $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); $cid_parts = array(url($path, array('absolute' => TRUE)), 'html'); $cid = sha1(implode(':', $cid_parts)); - $cache_entry = \Drupal::cache('page')->get($cid); + $cache_entry = \Drupal::cache('render')->get($cid); $this->assertIdentical($cache_entry->tags, $expected_tags); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php index 1264577..bd2ceb9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php @@ -141,7 +141,7 @@ protected function toggleFieldTranslatability($entity_type) { $field = FieldService::fieldInfo()->getField($entity_type, $field_name); $this->assertEqual($field->isTranslatable(), $translatable, 'Field translatability changed.'); } - \Drupal::cache('field')->deleteAll(); + \Drupal::cache('entity')->deleteAll(); } } diff --git a/core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php b/core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php index f325b85..9b93095 100644 --- a/core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php @@ -126,7 +126,7 @@ function testProcessedCache() { // Load the entity and check that the field cache contains the expected // data. $entity = entity_load($entity_type, $entity->id()); - $cache = \Drupal::cache('field')->get("field:$entity_type:" . $entity->id()); + $cache = \Drupal::cache('entity')->get("field:$entity_type:" . $entity->id()); $this->assertEqual($cache->data, array( Language::LANGCODE_NOT_SPECIFIED => array( 'summary_field' => array( @@ -156,7 +156,7 @@ function testProcessedCache() { ), ), ); - \Drupal::cache('field')->set("field:$entity_type:" . $entity->id(), $data); + \Drupal::cache('entity')->set("field:$entity_type:" . $entity->id(), $data); $entity = entity_load($entity_type, $entity->id(), TRUE); $this->assertEqual($entity->summary_field->processed, 'Cached processed value'); $this->assertEqual($entity->summary_field->summary_processed, 'Cached summary processed value'); diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php index cfad8fe..526336d 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php @@ -32,9 +32,18 @@ var $storage = array(); /** - * What table to store data in. + * Which cache bin to store the rendered output in. + * + * @var string + */ + protected $outputBin = 'render'; + + /** + * Which cache bin to store query results in. + * + * @var string */ - var $table = 'views_results'; + protected $resultsBin = 'path'; /** * Stores the cache ID used for the results cache. @@ -125,12 +134,12 @@ public function cacheSet($type) { 'total_rows' => isset($this->view->total_rows) ? $this->view->total_rows : 0, 'current_page' => $this->view->getCurrentPage(), ); - \Drupal::cache($this->table)->set($this->generateResultsKey(), $data, $this->cacheSetExpire($type), $this->getCacheTags()); + \Drupal::cache($this->resultsBin)->set($this->generateResultsKey(), $data, $this->cacheSetExpire($type), $this->getCacheTags()); break; case 'output': $this->storage['output'] = $this->view->display_handler->output; $this->gatherHeaders(); - \Drupal::cache($this->table)->set($this->generateOutputKey(), $this->storage, $this->cacheSetExpire($type), $this->getCacheTags()); + \Drupal::cache($this->outputBin)->set($this->generateOutputKey(), $this->storage, $this->cacheSetExpire($type), $this->getCacheTags()); break; } } @@ -149,7 +158,7 @@ public function cacheGet($type) { case 'results': // Values to set: $view->result, $view->total_rows, $view->execute_time, // $view->current_page. - if ($cache = \Drupal::cache($this->table)->get($this->generateResultsKey())) { + if ($cache = \Drupal::cache($this->resultsBin)->get($this->generateResultsKey())) { if (!$cutoff || $cache->created > $cutoff) { $this->view->result = $cache->data['result']; $this->view->total_rows = $cache->data['total_rows']; @@ -160,7 +169,7 @@ public function cacheGet($type) { } return FALSE; case 'output': - if ($cache = \Drupal::cache($this->table)->get($this->generateOutputKey())) { + if ($cache = \Drupal::cache($this->outputBin)->get($this->generateOutputKey())) { if (!$cutoff || $cache->created > $cutoff) { $this->storage = $cache->data; $this->view->display_handler->output = $cache->data['output']; diff --git a/core/modules/views/views.install b/core/modules/views/views.install index d3c0dee..8d4ea91 100644 --- a/core/modules/views/views.install +++ b/core/modules/views/views.install @@ -21,9 +21,8 @@ function views_install() { */ function views_schema_0() { module_load_install('system'); - // Add the cache_views_info and cache_views_results tables. + // Add the cache_views_info table. $cache_schema = system_schema_cache_8007(); $schema['cache_views_info'] = $cache_schema; - $schema['cache_views_results'] = $cache_schema; return $schema; } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 1d1f1b5..6df7008 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -493,7 +493,9 @@ function views_language_list($field = 'name', $flags = Language::STATE_ALL) { */ function views_field_instance_config_create(FieldInstanceConfigInterface $field_instance) { \Drupal::cache('views_info')->deleteAll(); - \Drupal::cache('views_results')->deleteAll(); + // @todo: Is this necessary? + \Drupal::cache('path')->deleteAll(); + \Drupal::cache('render')->deleteAll(); } /** @@ -501,7 +503,9 @@ function views_field_instance_config_create(FieldInstanceConfigInterface $field_ */ function views_field_instance_config_update(FieldInstanceConfigInterface $field_instance) { \Drupal::cache('views_info')->deleteAll(); - \Drupal::cache('views_results')->deleteAll(); + // @todo: Is this necessary? + \Drupal::cache('path')->deleteAll(); + \Drupal::cache('render')->deleteAll(); } /** @@ -509,7 +513,9 @@ function views_field_instance_config_update(FieldInstanceConfigInterface $field_ */ function views_field_instance_config_delete(FieldInstanceConfigInterface $field_instance) { \Drupal::cache('views_info')->deleteAll(); - \Drupal::cache('views_results')->deleteAll(); + // @todo: Is this necessary? + \Drupal::cache('path')->deleteAll(); + \Drupal::cache('render')->deleteAll(); } /** diff --git a/core/modules/views/views.services.yml b/core/modules/views/views.services.yml index 30aa96a..23700fd 100644 --- a/core/modules/views/views.services.yml +++ b/core/modules/views/views.services.yml @@ -75,13 +75,6 @@ services: factory_method: get factory_service: cache_factory arguments: [views_info] - cache.views_results: - class: Drupal\Core\Cache\CacheBackendInterface - tags: - - { name: cache.bin } - factory_method: get - factory_service: cache_factory - arguments: [views_results] views.route_subscriber: class: Drupal\views\EventSubscriber\RouteSubscriber arguments: ['@entity.manager', '@state']