CoreShop
CoreShop copied to clipboard
[Perf] allow some requests to not require loading the cart
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | yes |
In 2.2.x, CoreShop\Bundle\CoreBundle\EventListener\RequestCartAvailability::checkCartAvailability
will skip loading the cart in specific cases (like the route being _wdt
, etc).
What would be useful here is to actually abstract this: allow developers to opt out of the cart requirement, meaning they could basically serve some requests without any database queries (if combined with #1803), this being an important property for very busy shops, for ESI fragments (Varnish) or requests which should be "realtime" (like search autocompletion).
Any concrete ideas?
@dpfaffenbauer yes: currently there are some items which are fetched in event listeners, regardless if they'll be required or not, this also applies to #1803.
We should instead aim to fetch / set those things just in time, as in if we know for sure they'll be required. Maybe we have some factory based magic for the cart? Meaning we only fetch it if the code requests it to begin with?
CartAvailability could be replaced with a change in the CartContext for example.
Yes, this could be done in general for other listeners too. Generally, any expensive operation should be done after an (implicit or explicit) opt-in, not opt-out.
Note, this also applies to \CoreShop\Bundle\CoreBundle\EventListener\RequestCartRecalculation::checkPriceRuleState