1.20.x cache.inc cache_clear_all($cid = NULL, string $bin = NULL, bool $wildcard = FALSE)

Clears data from the cache.

If called with the arguments $cid and $bin set to NULL or omitted, then expirable entries will be cleared from the page and layout bins, and the $wildcard argument is ignored.

Parameters

string|array|NULL $cid: The cache ID or an array of cache IDs. Otherwise, all cache entries that can expire are deleted.

string|NULL $bin: The cache bin whose data should be cleared. Mandatory argument if $cid is set.

bool $wildcard: If TRUE, the $cid argument must contain a string value and cache IDs starting with $cid are deleted in addition to the exact cache ID specified by $cid. If $wildcard is TRUE and $cid is '*', the entire cache is emptied.

The wildcard parameter is a legacy argument. If needing to do a full bin flush, use cache_flush() instead. Prefix-based flushes are also discouraged, as not all cache backends natively support wildcard functionality.

See also

cache_flush()

File

includes/cache.inc, line 169
Functions and interfaces for cache handling.

Code

function cache_clear_all($cid = NULL, string $bin = NULL, bool $wildcard = FALSE) {
  // Default value cache flush.
  if (!isset($cid) && !isset($bin)) {
    cache('layout_path')->flush();
    cache('page')->flush();
    return;
  }

  if (!$wildcard) {
    if (is_null($cid)) {
      cache($bin)->garbageCollection();
    }
    else {
      is_array($cid) ? cache($bin)->deleteMultiple($cid) : cache($bin)->delete($cid);
    }
  }
  else {
    if ($cid === '*') {
      cache($bin)->flush();
    }
    else {
      cache($bin)->deletePrefix($cid);
    }
  }
}