- 🇦🇺Australia mstrelan
To bike-shed here I would simply call it
createItems
or possiblycreateMultiple
, similar toEntityInterface::loadMultiple
.I'm not sure what is the BC way of adding methods to an interface. We could create a new interface that extends QueueInterface and provide a trait that has a default implementation with a simple loop.
It looks like we could easily refactor
\Drupal\Core\Queue\DatabaseQueue::doCreateItem
to insert multiple items at once with a bit of massaging. In fact, the simple_sitemap module already does this in SimpleSitemapQueue. Not quite sure about the return value though.At a glance the redis client already allows preprending multiple items, so redis module can easily make use of that too.
In core there are not a lot of places that could make use of this. I've identified the following:
_batch_populate_queue
- multiple batch operationslocale_cron_fill_queue
- same as above\Drupal\media\Entity\Media::postSave
- download thumbnails for multiple translations
So we're probably only saving a handful of queries there. But there are more places in contrib that could also make use of this. A few I see in the project I'm currently working on:
entity_reference_revisions_entity_delete
\Drupal\linkchecker\LinkCheckerService::queueLinks
\Drupal\workbench_email\EventSubscriber\WorkbenchTransitionEventSubscriber::onContentModerationTransition
I'm not sure that system.module is the right component though, so changing to base system.