cache_clear_all

Versions
4.6 – 4.7
cache_clear_all($cid = NULL, $wildcard = false)
5 – 6
cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE)
7
cache_clear_all($cid = NULL, $bin = NULL, $wildcard = FALSE)

Expire data from the cache. If called without arguments, expirable entries will be cleared from the cache_page and cache_block tables.

Parameters

$cid If set, the cache ID to delete. Otherwise, all cache entries that can expire are deleted.

$table If set, the table $table to delete from. Mandatory argument if $cid is set.

$wildcard If $wildcard is TRUE, cache IDs starting with $cid are deleted in addition to the exact cache ID specified by $cid. If $wildcard is TRUE and $cid is '*' then the entire table $table is emptied.

▾ 53 functions call cache_clear_all()

aggregator_refresh in modules/aggregator/aggregator.module
Checks a news feed for new items.
block_add_block_form_submit in modules/block/block.admin.inc
Save the new custom block.
block_admin_configure_submit in modules/block/block.admin.inc
block_admin_display_form_submit in modules/block/block.admin.inc
Process main blocks administration form submission.
block_box_delete_submit in modules/block/block.admin.inc
Deletion of custom blocks.
cache_clear_all in includes/cache.inc
Expire data from the cache. If called without arguments, expirable entries will be cleared from the cache_page and cache_block tables.
comment_admin_overview_submit in modules/comment/comment.admin.inc
Process comment_admin_overview form submissions.
comment_confirm_delete_submit in modules/comment/comment.admin.inc
Process comment_confirm_delete form submissions.
comment_multiple_delete_confirm_submit in modules/comment/comment.admin.inc
Process comment_multiple_delete_confirm form submissions.
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
drupal_flush_all_caches in includes/common.inc
Flush all cached data on the site.
drupal_process_form in includes/form.inc
This function is the heart of form API. The form gets built, validated and in appropriate cases, submitted.
drupal_rebuild_theme_registry in includes/theme.inc
Force the system to rebuild the theme registry; this should be called when modules are added to the system, or when a dynamic system needs to add more theme hooks.
filter_admin_configure_submit in modules/filter/filter.admin.inc
Clear the filter's cache when configuration settings are saved.
filter_admin_delete_submit in modules/filter/filter.admin.inc
Process filter delete form submission.
filter_admin_format_form_submit in modules/filter/filter.admin.inc
Process filter format form submissions.
filter_admin_order_submit in modules/filter/filter.admin.inc
Process filter order configuration form submission.
filter_cron in modules/filter/filter.module
Implementation of hook_cron().
locale in modules/locale/locale.module
Provides interface translation services.
locale_languages_delete_form_submit in includes/locale.inc
Process language deletion submissions.
locale_languages_overview_form_submit in includes/locale.inc
Process language overview form submissions, updating existing languages.
locale_translate_delete_form_submit in includes/locale.inc
Process string deletion submissions.
locale_translate_edit_form_submit in includes/locale.inc
Process string editing form submissions.
menu_cache_clear in includes/menu.inc
Clears the cached cached data for a single named menu.
menu_cache_clear_all in includes/menu.inc
Clears all cached menu data. This should be called any time broad changes might have been made to the router items or menu links.
menu_delete_menu_confirm_submit in modules/menu/menu.admin.inc
Delete a custom menu and all items in it.
node_access_rebuild in modules/node/node.module
Rebuild the node access database. This is occasionally needed by modules that make system-wide changes to access levels.
node_admin_nodes_submit in modules/node/node.admin.inc
Process node_admin_nodes form submissions.
node_delete in modules/node/node.module
Delete a node.
node_save in modules/node/node.module
Save a node object into the database.
poll_vote in modules/poll/poll.module
Submit handler for processing a vote
profile_admin_overview_submit in modules/profile/profile.admin.inc
Submit handler to update changed profile field weights and categories.
profile_field_delete_submit in modules/profile/profile.admin.inc
Process a field delete form submission.
profile_field_form_submit in modules/profile/profile.admin.inc
Process profile_field_form submissions.
system_cron in modules/system/system.module
Implementation of hook_cron().
system_modules_submit in modules/system/system.admin.inc
Submit callback; handles modules form submission.
system_settings_form_submit in modules/system/system.module
Execute the system_settings_form.
system_theme_settings_submit in modules/system/system.admin.inc
Process system_theme_settings form submissions.
system_update_6050 in modules/system/system.install
Clear any menu router blobs stored in the cache table.
taxonomy_del_term in modules/taxonomy/taxonomy.module
Delete a term.
taxonomy_del_vocabulary in modules/taxonomy/taxonomy.module
Delete a vocabulary.
taxonomy_save_term in modules/taxonomy/taxonomy.module
Helper function for taxonomy_form_term_submit().
taxonomy_save_vocabulary in modules/taxonomy/taxonomy.module
throttle_exit in modules/throttle/throttle.module
Implementation of hook_exit().
update_info_page in ./update.php
user_admin_perm_submit in modules/user/user.admin.inc
user_edit_submit in modules/user/user.pages.inc
user_profile_form_submit in modules/user/user.pages.inc
Submit function for the user account and profile editing form.
variable_del in includes/bootstrap.inc
Unset a persistent variable.
variable_set in includes/bootstrap.inc
Set a persistent variable.
_locale_import_po in includes/locale.inc
Parses Gettext Portable Object file information and inserts into database
_menu_clear_page_cache in includes/menu.inc
Helper function to clear the page and block caches at most twice per page load.
_node_access_rebuild_batch_finished in modules/node/node.module
Post-processing for node_access_rebuild_batch.

Code

includes/cache.inc, line 132

<?php
function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) {
  global $user;

  if (!isset($cid) && !isset($table)) {
    // Clear the block cache first, so stale data will
    // not end up in the page cache.
    cache_clear_all(NULL, 'cache_block');
    cache_clear_all(NULL, 'cache_page');
    return;
  }

  if (empty($cid)) {
    if (variable_get('cache_lifetime', 0)) {
      // We store the time in the current user's $user->cache variable which
      // will be saved into the sessions table by sess_write(). We then
      // simulate that the cache was flushed for this user by not returning
      // cached data that was cached before the timestamp.
      $user->cache = time();

      $cache_flush = variable_get('cache_flush_'. $table, 0);
      if ($cache_flush == 0) {
        // This is the first request to clear the cache, start a timer.
        variable_set('cache_flush_'. $table, time());
      }
      else if (time() > ($cache_flush + variable_get('cache_lifetime', 0))) {
        // Clear the cache for everyone, cache_lifetime seconds have
        // passed since the first request to clear the cache.
        db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
        variable_set('cache_flush_'. $table, 0);
      }
    }
    else {
      // No minimum cache lifetime, flush all temporary cache entries now.
      db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
    }
  }
  else {
    if ($wildcard) {
      if ($cid == '*') {
        db_query("DELETE FROM {". $table ."}");
      }
      else {
        db_query("DELETE FROM {". $table ."} WHERE cid LIKE '%s%%'", $cid);
      }
    }
    else {
      db_query("DELETE FROM {". $table ."} WHERE cid = '%s'", $cid);
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.