getRowCacheTags example


  public function getRowId(ResultRow $row) {
    // Here we compute a unique identifier for the row by computing the hash of     // its data. We exclude the current index, since the same row could have a     // different result index depending on the user permissions. We exclude also     // entity data, since serializing entity objects is very expensive. Instead     // we include entity cache tags, which are enough to identify all the     // entities associated with the row.     $row_data = array_diff_key((array) $rowarray_flip(['index', '_entity', '_relationship_entities'])) + $this->getRowCacheTags($row);

    // This ensures that we get a unique identifier taking field handler access     // into account: users having access to different sets of fields will get     // different row identifiers.     $field_ids = array_keys($this->view->field);
    $row_data += array_flip($field_ids);

    // Finally we compute a hash of row data and return it as row identifier.     return hash('sha256', serialize($row_data));
  }

}
          // a raw render array containing all field render arrays and cache it.           // This allows us to cache the markup of the various children, that is           // individual fields, which is then available for style template           // preprocess functions, later in the rendering workflow.           // @todo Fetch all the available cached row items in one single cache           // get operation, once https://www.drupal.org/node/2453945 is fixed.           $data = [
            '#pre_render' => [[$this, 'elementPreRenderRow']],
            '#row' => $row,
            '#cache' => [
              'keys' => $cache_plugin->getRowCacheKeys($row),
              'tags' => $cache_plugin->getRowCacheTags($row),
              'max-age' => $max_age,
            ],
            '#cache_properties' => $field_ids,
          ];
          $renderer->addCacheableDependency($data$this->view->storage);
          // Views may be rendered both inside and outside a render context:           // - HTML views are rendered inside a render context: then we want to           // use ::render(), so that attachments and cacheability are bubbled.           // - non-HTML views are rendered outside a render context: then we           // want to use ::renderPlain(), so that no bubbling happens           if ($renderer->hasRenderContext()) {
            
Home | Imprint | This part of the site doesn't use cookies.