function boost_cache_expire_by_db in Boost 6
Expires the static file cache for the given paths via database.
Parameters
$paths: Array of URL's
$debug: TRUE to display what would have happened
1 call to boost_cache_expire_by_db()
- boost_cache_expire_derivative in ./
boost.module - Finds all possible paths/redirects/aliases given the root path.
File
- ./
boost.module, line 3237 - Provides static file caching for Drupal text output. Pages, Feeds, ect...
Code
function boost_cache_expire_by_db($paths, $debug = FALSE) {
$hashes = array();
if (empty($paths)) {
return FALSE;
}
// Get all cache files directly associated with this path
foreach ($paths as $path) {
// With URL Variables
$html = boost_file_path($path, TRUE, BOOST_FILE_EXTENSION);
if ($html !== FALSE) {
$xml = boost_file_path($path, TRUE, BOOST_XML_EXTENSION);
$json = boost_file_path($path, TRUE, BOOST_JSON_EXTENSION);
// Hash the paths
$hashes[] = md5($html);
$hashes[] = md5($xml);
$hashes[] = md5($json);
}
// Without URL Variables
$html = boost_file_path($path, FALSE, BOOST_FILE_EXTENSION);
if ($html !== FALSE) {
$xml = boost_file_path($path, FALSE, BOOST_XML_EXTENSION);
$json = boost_file_path($path, FALSE, BOOST_JSON_EXTENSION);
// Hash the paths
$hashes[] = md5($html);
$hashes[] = md5($xml);
$hashes[] = md5($json);
}
}
$result = boost_db_multi_select_in('boost_cache', 'hash', "'%s'", $hashes);
// Eliminate duplicates with the key hash
$data = array();
$counter = 0;
$filenames = array();
if ($result) {
while ($info = db_fetch_array($result)) {
if (($info['page_callback'] == 'node' || $info['page_callback'] == 'taxonomy') && $info['page_id'] == 0) {
// If we can't get a 'lock' just expire the file
$filenames[] = $info['filename'];
}
elseif ($info['page_id'] != '' && $info['page_type'] != '' && $info['page_callback'] != '') {
// Use boost_cache_expire_router() if we can get a 'lock' on this item in the database
$hash = BOOST_FILE_PATH . $info['page_callback'] . $info['page_type'] . $info['page_id'];
$data[$hash] = $info;
}
else {
// If we can't get a 'lock' just expire the file
$filenames[] = $info['filename'];
}
}
// Expire all files that match up
if (!$debug) {
if ($data) {
boost_set_base_dir_in_array($data);
$counter += boost_cache_expire_router($data);
}
if ($filenames) {
$counter += boost_cache_flush_by_filename($filenames);
}
}
else {
boost_set_base_dir_in_array($data);
return array(
$data,
$filenames,
);
}
}
return $counter;
}