function views_content_cache_plugin_cache::cache_expire in Views content cache 7.3
Same name and namespace in other branches
- 6.2 views/views_content_cache_plugin_cache.inc \views_content_cache_plugin_cache::cache_expire()
Return the expiry time for this cache plugin.
This should be the last time that the content has changed, altered to allow for the the min/max lifetimes.
Overrides views_plugin_cache::cache_expire
File
- views/
views_content_cache_plugin_cache.inc, line 87 - Provides the Views content cache, views cache plugin.
Class
- views_content_cache_plugin_cache
- Simple caching of query results for Views displays. Includes listening for changes/posts/deletions of certain node types.
Code
function cache_expire($type) {
$cutoff = 0;
// Retrieve the latest update time matching the settings on this View.
$cid = array();
if (!empty($this->options['keys'])) {
foreach ($this->options['keys'] as $key_id => $key_values) {
if ($plugin = views_content_cache_get_plugin($key_id)) {
$cid[$key_id] = $plugin
->view_key($key_values, $this);
}
}
}
if (!empty($cid) && ($timestamp = views_content_cache_update_get($cid))) {
$cutoff = $timestamp;
}
// If there's a minimum lifetime, enforce it:
if ($min_lifespan = $this->options[$type . '_min_lifespan']) {
$min_lifespan = REQUEST_TIME - $min_lifespan;
$cutoff = min($min_lifespan, $cutoff);
}
// Only enforce a maximum lifetime if it's been specifically selected:
if ($max_lifespan = $this->options[$type . '_max_lifespan']) {
if ($max_lifespan != -1) {
$max_lifespan = REQUEST_TIME - $max_lifespan;
$cutoff = max($max_lifespan, $cutoff);
}
}
return $cutoff;
}