Apply custom cache tag for views row cache.

Created on 14 March 2021, about 4 years ago
Updated 17 April 2025, 3 days ago

Problem/Motivation

By default, the custom cache tag will only be applied to the views level.
Actually there will be a cache for each views result row. And the cache tag for each row are generated by below code. It will not apply the custom cache tag for the rows.

  public function getRowCacheTags(ResultRow $row) {
    $tags = !empty($row->_entity) ? $row->_entity->getCacheTags() : [];

    if (!empty($row->_relationship_entities)) {
      foreach ($row->_relationship_entities as $entity) {
        $tags = Cache::mergeTags($tags, $entity->getCacheTags());
      }
    }

    return $tags;
  }

Sometime we want to apply the custom tags to the row as well.

Proposed resolution

Just rewrite the function getRowCacheTags in the module to apply the custom cache tags.

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇨🇳China yechaozheng

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
Production build 0.71.5 2024