You are here

public function SearchApiTagCache::getCacheTags in Search API 8

Gets an array of cache tags for the current view.

Return value

string[] An array of cache tags based on the current view.

Overrides CachePluginBase::getCacheTags

File

src/Plugin/views/cache/SearchApiTagCache.php, line 80

Class

SearchApiTagCache
Defines a tag-based cache plugin for use with Search API views.

Namespace

Drupal\search_api\Plugin\views\cache

Code

public function getCacheTags() {
  $tags = $this->view->storage
    ->getCacheTags();

  // Add the list cache tag of the search index, so that the view will be
  // invalidated whenever the index is updated.
  $tag = 'search_api_list:' . $this
    ->getQuery()
    ->getIndex()
    ->id();
  $tags = Cache::mergeTags([
    $tag,
  ], $tags);

  // Also add the cache tags of the index itself, so that the view will be
  // invalidated if the configuration of the index changes.
  $index_tags = $this
    ->getQuery()
    ->getIndex()
    ->getCacheTagsToInvalidate();
  $tags = Cache::mergeTags($index_tags, $tags);
  return $tags;
}