function cache_clear_all in File Cache 5.5
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.
File
- ./
filecache.inc, line 125
Code
function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) {
global $user;
$path = variable_get('filecache_path', 'files/cache') . '/' . $table;
if (!isset($cid) || !isset($table)) {
cache_clear_all('*', !isset($table) ? 'cache_page' : $table);
return;
}
if ($wildcard) {
if (file_exists($path) && is_dir($path) && ($dir = opendir($path))) {
if ($cid == '*') {
$reg = '.*';
}
else {
$reg = '^' . urlencode($cid);
}
while ($file = readdir($dir)) {
if (!in_array($file, array(
'.',
'..',
)) && ereg($reg, $file) !== FALSE && !is_dir($path . '/' . $file)) {
unlink($path . '/' . $file);
}
}
}
}
elseif (file_exists($path . '/' . urlencode($cid))) {
unlink($path . '/' . urlencode($cid));
}
}