You are here

function hook_cache_flush in Drupal 10

Same name and namespace in other branches
  1. 8 core/core.api.php \hook_cache_flush()
  2. 9 core/core.api.php \hook_cache_flush()

Flush all persistent and static caches.

This hook asks your module to clear all of its static caches, in order to ensure a clean environment for subsequently invoked data rebuilds.

Do NOT use this hook for rebuilding information. Only use it to flush custom caches.

Static caches using drupal_static() do not need to be reset manually. However, all other static variables that do not use drupal_static() must be manually reset.

This hook is invoked by drupal_flush_all_caches(). It runs before module data is updated and before hook_rebuild().

See also

drupal_flush_all_caches()

hook_rebuild()

Related topics

2 string references to 'hook_cache_flush'
ConfigImportUITest::testImport in core/modules/config/tests/src/Functional/ConfigImportUITest.php
Tests importing configuration.
config_test_cache_flush in core/modules/config/tests/config_test/config_test.module
Implements hook_cache_flush().
3 functions implement hook_cache_flush()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

config_test_cache_flush in core/modules/config/tests/config_test/config_test.module
Implements hook_cache_flush().
locale_cache_flush in core/modules/locale/locale.module
Implements hook_cache_flush().
update_script_test_cache_flush in core/modules/system/tests/modules/update_script_test/update_script_test.module
Implements hook_cache_flush().
3 invocations of hook_cache_flush()
ConfigTranslationDeleteForm::submitForm in core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php
Form submission handler.
drupal_flush_all_caches in core/includes/common.inc
Rebuilds the container, flushes all persistent caches, resets all variables, and rebuilds all data structures.
ModuleInstaller::uninstall in core/lib/Drupal/Core/Extension/ModuleInstaller.php

File

core/core.api.php, line 2188
Documentation landing page and topics, plus core library hooks.

Code

function hook_cache_flush() {
  if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
    _update_cache_clear();
  }
}