You are here

function views_plugin_cache::cache_set in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 plugins/views_plugin_cache.inc \views_plugin_cache::cache_set()
  2. 7.3 plugins/views_plugin_cache.inc \views_plugin_cache::cache_set()

Save data to the cache.

A plugin should override this to provide specialized caching behavior.

1 method overrides views_plugin_cache::cache_set()
views_plugin_cache_none::cache_set in plugins/views_plugin_cache_none.inc
Save data to the cache.

File

plugins/views_plugin_cache.inc, line 81

Class

views_plugin_cache
The base plugin to handle caching.

Code

function cache_set($type) {
  switch ($type) {
    case 'query':

      // Not supported currently, but this is certainly where we'd put it.
      break;
    case 'results':
      $data = array(
        'result' => $this->view->result,
        'total_rows' => $this->view->total_rows,
        'pager' => $this->view->pager,
      );
      cache_set($this
        ->get_results_key(), $data, $this->table, $this
        ->cache_set_expire($type));
      break;
    case 'output':
      $this
        ->gather_headers();
      $this->storage['output'] = $this->view->display_handler->output;
      cache_set($this
        ->get_output_key(), $this->storage, $this->table, $this
        ->cache_set_expire($type));
      break;
  }
}