function varnish_cron in Varnish 5
Implementation of hook_cron
File
- ./
varnish.module, line 142 - varnish.module Provide drupal hooks for integration with the Varnish control layer.
Code
function varnish_cron() {
if (variable_get('varnish_flush_cron', 0)) {
if (variable_get('cache_lifetime', 0)) {
$cache_flush = variable_get('cache_flush_varnish', 0);
if ($cache_flush == 0) {
// This is the first request to clear the cache, start a timer.
variable_set('cache_flush_varnish', time());
}
else {
if (time() > $cache_flush + variable_get('cache_lifetime', 0)) {
variable_set('cache_flush_varnish', 0);
varnish_purge_all_pages();
}
}
}
else {
varnish_purge_all_pages();
}
}
}