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 table.

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 set to TRUE, the $cid is treated as a substring to match rather than a complete ID. The match is a right hand match. If '*' is given as $cid, the table $table will be emptied.

▾ 43 functions call cache_clear_all()

aggregator_refresh in modules/aggregator/aggregator.module
Checks a news feed for new items.
block_admin_configure_submit in modules/block/block.module
block_admin_display_submit in modules/block/block.module
Process main block administration form submission.
block_box_delete_submit in modules/block/block.module
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 table.
comment_admin_overview_submit in modules/comment/comment.module
Execute the chosen 'Update option' on the selected comments, such as publishing, unpublishing or deleting.
comment_confirm_delete_submit in modules/comment/comment.module
comment_multiple_delete_confirm_submit in modules/comment/comment.module
Perform the actual comment deletion.
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
drupal_clear_css_cache in includes/common.inc
Delete all cached CSS files.
filter_admin_configure_submit in modules/filter/filter.module
Clear the filter's cache when configuration settings are saved.
filter_admin_delete_submit in modules/filter/filter.module
Process filter delete form submission.
filter_admin_format_form_submit in modules/filter/filter.module
Process filter format form submissions.
filter_admin_order_submit in modules/filter/filter.module
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_admin_manage_delete_form_submit in modules/locale/locale.module
Process language deletion submissions.
menu_rebuild in includes/menu.inc
Populate the database representation of the menu.
module_disable in includes/module.inc
Disable a given set of modules.
module_enable in includes/module.inc
Enable a given list of modules.
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.module
Submit the node administration update form.
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
Callback for processing a vote
profile_field_delete_submit in modules/profile/profile.module
Process a field delete form submission.
profile_field_form_submit in modules/profile/profile.module
Process profile_field_form submissions.
system_theme_settings_submit in modules/system/system.module
system_update_1005 in modules/system/system.install
system_update_1011 in modules/system/system.install
system_update_113 in modules/system/system.install
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_do_updates in ./update.php
Perform updates for one second or until finished.
user_admin_account_submit in modules/user/user.module
Submit the user administration update form.
user_edit_submit in modules/user/user.module
variable_del in includes/bootstrap.inc
Unset a persistent variable.
variable_set in includes/bootstrap.inc
Set a persistent variable.
_locale_admin_manage_screen_submit in includes/locale.inc
Process locale admin manager form submissions.
_locale_import_po in includes/locale.inc
Parses Gettext Portable Object file information and inserts into database

Code

includes/cache.inc, line 120

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

  if (!isset($cid) && !isset($table)) {
    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.