Updated: Comment #N

Problem/Motivation

We don't have any cache tags for views plugins and handlers. The definition caches.

Proposed resolution

Add them!

Remaining tasks

Decide on which tags we want to add. extension? plugin type?

User interface changes

None

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

Status: Active » Needs review
FileSize
1.63 KB

Maybe just KISS, like this?

dawehner’s picture

Why would ever someone invalidate extension => 'views'?

damiankloip’s picture

views_invalidate_cache() in the future?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Oh I see

damiankloip’s picture

Wim Leers’s picture

Title: Add cache tags to views plugin definitions » Add cache tags to Views plugin definitions
Issue tags: +D8 cacheability, +Performance

This is in line with what LibraryDiscovery does:

    $this->cache->set('library:info:' . $extension, $information, Cache::PERMANENT, array(
      'extension' => array(TRUE, $extension),
      'library_info' => array(TRUE),
    ));

RTBC +1

dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php
@@ -57,7 +57,7 @@ public function __construct($handler_type, \Traversable $namespaces, ViewsData $
-    $this->setCacheBackend($cache_backend, $language_manager, "views:$handler_type");
+    $this->setCacheBackend($cache_backend, $language_manager, "views:$handler_type", array('extension' => array(TRUE, 'views')));

+++ b/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php
@@ -44,7 +44,7 @@ public function __construct($type, \Traversable $namespaces, CacheBackendInterfa
-    $this->setCacheBackend($cache_backend, $language_manager, "views:{$type}_plugins");
+    $this->setCacheBackend($cache_backend, $language_manager, "views:{$type}_plugins", array('extension' => array(TRUE, 'views')));

On the longrun we probably want to store all of that information in one cache entry , but this is work for another issue. You need all of them anyway.

damiankloip’s picture

Title: Add cache tags to Views plugin definitions » Add cache tags to Views data and plugin definition cache entries
Status: Reviewed & tested by the community » Needs review
FileSize
6.32 KB
4.69 KB

Can we slightly extend this issue as it is teeny anyway? :) We need tags on views data too, we also might as well implement these for a couple of things.

And yes, we ideally do want to consolidate plugins into a single cache entry. I have been speaking to msonnabaum about this too.

damiankloip’s picture

dawehner’s picture

And yes, we ideally do want to consolidate plugins into a single cache entry. I have been speaking to msonnabaum about this too.

Afaik this was was worked on in some other issue.

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
@@ -165,7 +166,8 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
+          $id = $this->view->storage->id();
+          \Drupal::cache('data')->set($cid, $this->options, Cache::PERMANENT, array('extension' => array(TRUE, 'views'), 'view' => array($id => $id)));

array(TRUE, 'views') is a little bit odd, can you elobarete why this is needed?

damiankloip’s picture

See Wim's comment in #6. If we have extension tags we get good flexibility to e.g. just clear extension:views tag and clear out plugin definitions, views data etc. Otherwise we have to truncate whole tables every time.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Oh I see, thank you!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: 2226613-8.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
6.34 KB

Just a reroll.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed cce2380 and pushed to 8.x. Thanks!

  • Commit cce2380 on 8.x by alexpott:
    Issue #2226613 by damiankloip: Add cache tags to Views data and plugin...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.