Convert CacheTagsInvalidator to use a service collector

Created on 19 January 2024, 11 months ago
Updated 26 February 2024, 10 months ago

Problem/Motivation

In 📌 Fork Symfony's ContainerAwareTrait and ContainerAwareInterface into core Needs work we are trying to reduce the use of ContainerAwareTrait as Symfony has deprecated it.

CacheTagsInvalidator is container aware because it needs to retrieve all cache bins by ID.

Instead of injecting the entire container we can inject the bins via a service collector method.

Steps to reproduce

Proposed resolution

Add service collector tags to CacheTagsInvalidator.

We already use service collectors for the invalidator services.

Merge request link

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

11.0 🔥

Component
Cache 

Last updated 2 days ago

Created by

🇬🇧United Kingdom longwave UK

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

Merge Requests

Comments & Activities

  • Issue created by @longwave
  • Merge request !6247Convert CacheTagsInvalidator. → (Open) created by longwave
  • Status changed to Needs review 11 months ago
  • 🇬🇧United Kingdom longwave UK
  • Status changed to Needs work 11 months ago
  • 🇬🇧United Kingdom longwave UK
  • Status changed to Needs review 11 months ago
  • 🇬🇧United Kingdom longwave UK
  • Pipeline finished with Failed
    11 months ago
    #80708
  • Status changed to Needs work 11 months ago
  • 🇳🇱Netherlands spokje

    PHPCS upset about now-useless use statement.

  • Status changed to Needs review 11 months ago
  • 🇬🇧United Kingdom longwave UK
  • Pipeline finished with Success
    11 months ago
    #80744
  • Pipeline finished with Canceled
    11 months ago
    #80762
  • Pipeline finished with Success
    11 months ago
    #80763
  • 🇳🇱Netherlands spokje

    FWIW: One nitpick, one question and a general "I don't fully grok the test before nor after, but I'm pretty sure it's testing the same thing in both cases.".

  • 🇬🇧United Kingdom longwave UK

    Addressed feedback.

    Regarding the test: Previously the getInvalidatorCacheBins() looped through both non-memory and memory cache parameters, and then could handle services that do and don't implement CacheTagsInvalidatorInterface, so four cases in total. Now we don't need the parameters or cache bin types, the test only needs to check services that do and don't implement that interface, so there are only two cases - the memory-specific ones are redundant.

  • Status changed to RTBC 11 months ago
  • 🇳🇱Netherlands spokje

    Thanks @longwave, I kinda sorta figured that about the test, all other feedback is addressed: => RTBC.

  • 🇬🇧United Kingdom longwave UK
  • Status changed to Needs work 11 months ago
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    We cannot mix cache bins and memory cache bins as the latter do not 100% behave as a cache bin. For more info, see 📌 Fix MemoryCache discovery and DX Needs review

  • Status changed to Needs review 11 months ago
  • 🇬🇧United Kingdom longwave UK

    I get why they need to be separated in the cache factory, but not in the invalidator; as long as they implement the interface normal bins and memory bins are invalidated in the same way.

  • Status changed to Needs work 11 months ago
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    As I mentioned in the review, will ask for a second opinion on whether we need to be this strict with keeping the two separated. Still NW because of the property typehint suggesting something that may not be true.

  • Status changed to Needs review 11 months ago
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Sorry, in my latest review comment I misread a few lines. The property can be typehinted as such as you check for the interface when the service is collecting the tagged services.

  • Status changed to RTBC 11 months ago
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    To be fair, now that I've taken a closer look and that you're checking the tagged services for the invalidator interface, I'm less fussed about it. The code makes it clear that you're not interested in the cache backends as caches, but rather as services that might implement the cache tags invalidator interface.

    Just poked @catch on Slack and he also seems to be fine with it under the circumstances presented here. Sorry about the previous noise but seeing the two types of cache backends mixed together in one property automatically raised a red flag with me. After further review, it's actually quite OK the way you implemented it.

    RTBC

  • 🇬🇧United Kingdom longwave UK

    No worries, I appreciate thoughtful reviews that take time to question what I did and why, especially when it might have side effects elsewhere.

    Applied the comment improvement, leaving at RTBC.

  • Pipeline finished with Success
    11 months ago
    Total: 804s
    #85375
    • catch committed 8bc5040e on 11.x
      Issue #3415940 by longwave, kristiaanvandeneynde, Spokje: Convert...
  • Status changed to Fixed 11 months ago
  • 🇬🇧United Kingdom catch

    Agreed that for tag invalidation we don't need to make the persistent/memory distinction. Committed/pushed to 11.x, thanks!

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

Production build 0.71.5 2024