Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
- Drupal\Core\Cache\DatabaseBackend makes use of 3 drupal_static() variables that are reset in WebTestBase::refreshVariables().
- Drupal\Core\Cache\ChainedFastBackend has a protected instance variable, $lastWriteTimestamp, that has no API for resetting, causing test failures in #2248767: Use fast, local cache back-end (APCu, if available) for low-write caches (bootstrap, discovery, and config) due to cache clears in a web request not propagating to the CLI process running the test. That issue is exploring adding a TTL to that instance variable of 0.3 seconds, but seems fragile to rely on that always being short enough for proper clearing within tests.
Proposed resolution
Does it make sense to add some kind of reset() method to CacheBackendInterface, or should each use case have its own dedicated API that's part of a different interface that specific backends could choose to implement or not?
Remaining tasks
?
User interface changes
None
API changes
?
Comment | File | Size | Author |
---|---|---|---|
#3 | 2311945-3.patch | 538 bytes | olli |
Comments
Comment #1
BerdirI think that one effect of #918538: Decouple cache tags from cache bins will be that those drupal_static()'s can go, as it will be just part of the service instance of the shared cache tags service. That said, that issue has been turning in cycles for a long time now.
Comment #2
BerdirI'm now doing that there, so closing this as duplicate.
Comment #3
olli CreditAttribution: olli commentedFound a @todo linking here.
This is what we currently have in WebTestBase::refreshVariables():
I think that the issue linked in #1 fixed only the first bullet in issue summary by replacing drupal_static()s with resetChecksums().
Comment #4
BerdirFair enough :)
Comment #5
BerdirActually, based on a discussion I just had in IRC with @WimLeers and @catch about #2501117: Add static caching for PermissionsHashGenerator::generate(), let's add this method to an optional inteface (CacheBackendResetInterface? )and check for that interface instead of is_callable().
Comment #6
Wim LeersYep, see #2501117-37: Add static caching for PermissionsHashGenerator::generate() for the rationale.
Comment #7
Wim LeersBetter title. Feel free to change.
Comment #10
Fabianx CreditAttribution: Fabianx as a volunteer commentedCache collectors need to call this as well.