The cache_tags.invalidator service no longer uses service collectors to gather cache tag invalidators and cache bins. They are now passed to the constructor as tagged iterators, so services are only initialised when invalidateTags() is called. This avoids circular references during container build and stops every cache bin being loaded early.
CacheTagsInvalidator::__construct() now takes three arguments:
public function __construct(
protected iterable $invalidators = [],
protected iterable $bins = [],
protected iterable $memoryBins = [],
)
The $invalidators and $bins properties are now typed iterable. The bin iterators can contain cache bins that don't implement CacheTagsInvalidatorInterface, and these are skipped when tags are invalidated.
The addInvalidator() and addBin() methods will continue to work.
If you extend CacheTagsInvalidator and override the constructor, call the parent constructor with the tagged iterators. If you replace the cache_tags.invalidator service definition, pass the same arguments:
cache_tags.invalidator:
class: Drupal\Core\Cache\CacheTagsInvalidator
arguments: [!tagged_iterator cache_tags_invalidator, !tagged_iterator cache.bin, !tagged_iterator cache.bin.memory]
Services tagged with cache_tags_invalidator, cache.bin or cache.bin.memory don't need to change.