Skip to content

Instantly share code, notes, and snippets.

@znerol
Created September 24, 2015 12:56
Show Gist options
  • Save znerol/261fed072cc24222445e to your computer and use it in GitHub Desktop.
Save znerol/261fed072cc24222445e to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_expire_cache().
*
* Expire cache support for the builtin cache handler.
*/
function authcache_builtin_expire_v2_expire_cache($urls, $wildcards, $object_type, $object) {
$cids = array();
$wildcard_cids = array();
$authcache_urls = array();
foreach ($urls as $path => $url) {
list ($path, $options) = $url;
$options['absolute'] = FALSE;
$authcache_urls[$path] = url($path, $options);
}
foreach (authcache_enum_keys() as $key) {
foreach ($authcache_urls as $path => $url) {
$cid = $key . $url;
if (empty($wildcards[$path])) {
$cids[] = $cid;
}
else {
$wildcard_cids[] = $cid;
}
}
}
if (!empty($cids)) {
cache_clear_all($cids, 'cache_page');
}
foreach ($wildcard_cids as $cid) {
cache_clear_all($cid, 'cache_page', TRUE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment