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.

Parameters

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

$wildcard If set to true, the $cid is treated as a substring to match rather than a complete ID.

▾ 31 functions call cache_clear_all()

aggregator_refresh in modules/aggregator.module
Checks a news feed for new items.
block_admin_configure_submit in modules/block.module
block_admin_display_submit in modules/block.module
Process main block administration form submission.
block_box_delete_confirm_submit in modules/block.module
Deletion of custom blocks.
comment_admin_overview_submit in modules/comment.module
Execute the chosen 'Update option' on the selected comments, such as publishing, unpublishing or deleting.
comment_confirm_delete_submit in modules/comment.module
comment_multiple_delete_confirm_submit in modules/comment.module
Perform the actual comment deletion.
comment_save in modules/comment.module
Accepts a submission of new or changed comment content.
filter_admin_delete_submit in modules/filter.module
Process filter delete form submission.
filter_admin_format_form_submit in modules/filter.module
Process filter format form submissions.
filter_admin_order_submit in modules/filter.module
Process filter order configuration form submission.
locale in modules/locale.module
Provides interface translation services.
locale_admin_manage_delete_form_submit in modules/locale.module
Process language deletion submissions.
menu_rebuild in includes/menu.inc
Populate the database representation of the menu.
node_admin_nodes_submit in modules/node.module
Generate the content administration overview.
node_delete in modules/node.module
Delete a node.
node_save in modules/node.module
Save a node object into the database.
poll_vote in modules/poll.module
Callback for processing a vote
profile_field_delete_submit in modules/profile.module
Process a field delete form submission.
profile_field_form_submit in modules/profile.module
Process profile_field_form submissions.
system_update_113 in database/updates.inc
taxonomy_del_term in modules/taxonomy.module
taxonomy_del_vocabulary in modules/taxonomy.module
taxonomy_save_term in modules/taxonomy.module
taxonomy_save_vocabulary in modules/taxonomy.module
throttle_exit in modules/throttle.module
Implementation of hook_exit().
user_edit_submit in modules/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/bootstrap.inc, line 395

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

  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', 0);
      if ($cache_flush == 0) {
        // This is the first request to clear the cache, start a timer.
        variable_set('cache_flush', time());
      }
      else if (time() > ($cache_flush + variable_get('cache_lifetime', 0))) {
        // Clear the cache for everyone, cache_flush_delay seconds have
        // passed since the first request to clear the cache.
        db_query("DELETE FROM {cache} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
        variable_set('cache_flush', 0);
      }
    }
    else {
      // No minimum cache lifetime, flush all temporary cache entries now.
      db_query("DELETE FROM {cache} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
    }
  }
  else {
    if ($wildcard) {
      db_query("DELETE FROM {cache} WHERE cid LIKE '%%%s%%'", $cid);
    }
    else {
      db_query("DELETE FROM {cache} 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.