You are here

function CachePluginBase::cache_set in Views (for Drupal 7) 8.3

Save data to the cache.

A plugin should override this to provide specialized caching behavior.

1 method overrides CachePluginBase::cache_set()
None::cache_set in lib/Drupal/views/Plugin/views/cache/None.php
Save data to the cache.

File

lib/Drupal/views/Plugin/views/cache/CachePluginBase.php, line 133
Definition of Drupal\views\Plugin\views\cache\CachePluginBase.

Class

CachePluginBase
The base plugin to handle caching.

Namespace

Drupal\views\Plugin\views\cache

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' => isset($this->view->total_rows) ? $this->view->total_rows : 0,
        'current_page' => $this->view
          ->getCurrentPage(),
      );
      cache($this->table)
        ->set($this
        ->generateResultsKey(), $data, $this
        ->cache_set_expire($type));
      break;
    case 'output':
      $this
        ->gather_headers();
      $this->storage['output'] = $this->view->display_handler->output;
      cache($this->table)
        ->set($this
        ->generateOutputKey(), $this->storage, $this
        ->cache_set_expire($type));
      break;
  }
}