function CachePluginBase::cache_set

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 drupal/core/modules/views/lib/Drupal/views/Plugin/views/cache/None.php
Overrides \Drupal\views\Plugin\views\cache\CachePluginBase::cache_set().

File

drupal/core/modules/views/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->storage['output'] = $this->view->display_handler->output;
      $this
        ->gather_headers();
      cache($this->table)
        ->set($this
        ->generateOutputKey(), $this->storage, $this
        ->cache_set_expire($type));
      break;
  }
}