public function CachePluginBase::cacheSet

Save data to the cache.

A plugin should override this to provide specialized caching behavior.

1 method overrides CachePluginBase::cacheSet()
None::cacheSet in drupal/core/modules/views/lib/Drupal/views/Plugin/views/cache/None.php
Replace the cache set logic so it does not set a cache item at all.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php, line 118
Definition of Drupal\views\Plugin\views\cache\CachePluginBase.

Class

CachePluginBase
The base plugin to handle caching.

Namespace

Drupal\views\Plugin\views\cache

Code

public function cacheSet($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
        ->cacheSetExpire($type));
      break;
    case 'output':
      $this->storage['output'] = $this->view->display_handler->output;
      $this
        ->gatherHeaders();
      cache($this->table)
        ->set($this
        ->generateOutputKey(), $this->storage, $this
        ->cacheSetExpire($type));
      break;
  }
}