You are here

public function CustomTag::cacheGet in Views Custom Cache Tags 8

Retrieve data from the cache.

A plugin should override this to provide specialized caching behavior.

Parameters

$type: The cache type, either 'query', 'result'.

Return value

bool TRUE if data has been taken from the cache, otherwise FALSE.

Overrides CachePluginBase::cacheGet

File

src/Plugin/views/cache/CustomTag.php, line 129
Contains \Drupal\views_custom_cache_tag\Plugin\views\cache\CustomTag.

Class

CustomTag
Simple caching of query results for Views displays.

Namespace

Drupal\views_custom_cache_tag\Plugin\views\cache

Code

public function cacheGet($type) {
  $result = parent::cacheGet($type);

  // This can be used to debug/test the views cache result.
  if ($type == 'results' && !$result && \Drupal::state()
    ->get('views_custom_cache_tag.execute_debug', FALSE)) {
    $this
      ->messenger()
      ->addMessage('Executing view ' . $this->view->storage
      ->id() . ':' . $this->view->current_display . ':' . implode(',', $this->view->args) . ' (' . implode(',', $this->view
      ->getCacheTags()) . ')');
  }
  return $result;
}