views_content_cache_test_plugin_cache.inc in Views content cache 6.2
File
tests/views/views_content_cache_test_plugin_cache.inc
View source
<?php
class views_content_cache_test_plugin_cache extends views_content_cache_plugin_cache {
function post_render(&$output) {
if (!empty($this->view->build_info['cached_results'])) {
$output .= '[served results from views_content_cache]';
}
}
function cache_get($type) {
$cutoff = $this
->cache_expire($type);
switch ($type) {
case 'query':
return FALSE;
case 'results':
if ($cache = cache_get($this
->get_results_key(), $this->table)) {
if (!$cutoff || $cache->created > $cutoff) {
$this->view->result = $cache->data['result'];
$this->view->total_rows = $cache->data['total_rows'];
$this->view->pager = isset($cache->data['pager']) ? $cache->data['pager'] : NULL;
$this->view->execute_time = 0;
$this->view->build_info['cached_results'] = TRUE;
return TRUE;
}
}
return FALSE;
case 'output':
if ($cache = cache_get($this
->get_output_key(), $this->table)) {
if (!$cutoff || $cache->created > $cutoff) {
$this->storage = $cache->data;
$this->view->display_handler->output = $cache->data['output'] . '[Served output from views_content_cache]' . "{$type}: Maximum age: " . format_interval($cache->created - $cutoff);
$this
->restore_headers();
return TRUE;
}
elseif (!empty($cutoff)) {
print_r('Results to old: ' . format_interval($cache->created - $cutoff));
}
}
return FALSE;
}
}
}