function views_plugin_cache::cache_get

Retrieve data from the cache.

A plugin should override this to provide specialized caching behavior.

1 call to views_plugin_cache::cache_get()
views_plugin_cache_time::cache_get in plugins/views_plugin_cache_time.inc
Retrieve data from the cache.
2 methods override views_plugin_cache::cache_get()
views_plugin_cache_none::cache_get in plugins/views_plugin_cache_none.inc
Retrieve data from the cache.
views_plugin_cache_time::cache_get in plugins/views_plugin_cache_time.inc
Retrieve data from the cache.

File

plugins/views_plugin_cache.inc, line 116

Class

views_plugin_cache
The base plugin to handle caching.

Code

public function cache_get($type) {
    $cutoff = $this->cache_expire($type);
    switch ($type) {
        case 'query':
            // Not supported currently, but this is certainly where we'd put it.
            return FALSE;
        case 'results':
            // Values to set: $view->result, $view->total_rows, $view->execute_time,
            // $view->current_page.
            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
                        ->set_current_page($cache->data['current_page']);
                    $this->view->execute_time = 0;
                    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'];
                    $this->restore_headers();
                    return TRUE;
                }
            }
            return FALSE;
    }
}