Batch together invalidations using BatchHandlerTrait
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3593413. -->
Reported by: [dpi](https://www.drupal.org/user/81431)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When ran through purge_processor_cron.module, it looks like all invalidations in the queue are buffered and sent in one go, right through to the plugin in one batch. This allows purge plugins to reduce many invalidations to one (or much less than many).</p>
<p>Right now each invalidation is executed atomically/transactionally, so a Purge plugin is unable to collate and reduce invalidations.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Messenger provides BatchTrait which allows buffering of many like messages, which are then flushed together as on according to bus/transit logic.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Ensure the current SM infrastructure is capable of auto-flushing. I understand there was some bugs in some versions where things wouldnt get flushed automatically. Maybe <a href="https://github.com/symfony/symfony/pull/63277">https://github.com/symfony/symfony/pull/63277</a> can help out.</p>
<p><a href="https://symfony.com/doc/current/messenger.html#process-messages-by-batches">https://symfony.com/doc/current/messenger.html#process-messages-by-batches</a></p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>None</p>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
issue