Problem/Motivation

If cached data is deleted on one webhead, it must be prevented that this data is used on any other webhead. The ChainedFast backend ensures this by invalidating all webhead cache data on any write to the consistent backend (see ChainedFastBackend::getMultiple).
This is very inefficient and raises the question, under which conditions is that coordination between webheads needed in the first place.

That question, and an alternative chained cache API was pioneered in the DCache module (see API).

Proposed resolution

* Provide a cache API without CacheItem::Delete, so that cache tags are the only way to invalidate cache items
* Drop the high-cost coordination-beween-webheads logic

Remaining tasks

- Add a POC
- Bikeshed
- Implement an API
- Deprecate the old API
- Profit

User interface changes

None.

API changes

API addition, then deprecation.

Data model changes

Full cache tags coverage is mandatory.

Comments

geek-merlin created an issue. See original summary.

geek-merlin’s picture

Project: Geek Merlin's Issue Incubator » Drupal core
Version: » 11.0.x-dev
Component: Code » cache system
Issue summary: View changes
geek-merlin’s picture

Version: 11.0.x-dev » 10.1.x-dev
geek-merlin’s picture

Title: (CORE) Replace CacheItem::Delete with mandatory cache tags, to remove the need to coordinate caches between webheads » Replace CacheItem::Delete with mandatory cache tags, to remove the need to coordinate caches between webheads

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

berdir’s picture

ChainedFastBackend is meant for bins that are read often and rarely written.

On most sites, the fact that it invalidated all local storages on any cache tag invalidation was a much bigger issue and that has been changed now in #3334489: ChainedFastBackend invalidates all items when cache tags are invalidated.

When used on the proper bins and there's no misbehaving code (that does stuff like write config on any/many requests), invalidate-on-save is far more efficient than cache tags, which literally are "high-cost coordination-beween-webheads logic", as they require an extra query on every cache get.

Also somewhat related, the redis project now includes an integration with the relay php extension, which includes a native implementation that also listens on changes in redis and updates itself and therefore removes the need for the invalidate-on-save.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.