function views_content_cache_plugin_cache::cache_expire in Views content cache 6.2
Same name and namespace in other branches
- 7.3 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.
1 call to views_content_cache_plugin_cache::cache_expire()
- views_content_cache_test_plugin_cache::cache_get in tests/
views/ views_content_cache_test_plugin_cache.inc - Retrieve data from the cache.
File
- views/
views_content_cache_plugin_cache.inc, line 101
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'])) {
// TODO: Don't store the keys like this.
$keys = array_merge(!empty($this->options['keys']['AND']) ? $this->options['keys']['AND'] : array(), !empty($this->options['keys']['OR']) ? $this->options['keys']['OR'] : array());
// Backwards compatible with older options:
unset($this->options['keys']['AND'], $this->options['keys']['OR']);
$keys = array_merge($keys, $this->options['keys']);
foreach ($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 = 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 = time() - $max_lifespan;
$cutoff = max($max_lifespan, $cutoff);
}
}
return $cutoff;
}