You are here

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

Same name and namespace in other branches
  1. 6.2 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 75

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':
      if ($this
        ->get_results_key() !== FALSE) {
        $data = array(
          'result' => $this->view->result,
          'total_rows' => $this->view->total_rows,
          'current_page' => $this->view
            ->get_current_page(),
        );
        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;
  }
}