symfony

Nicolas Grekas shared on the official Symfony blog a new feature that will be coming in the next Symfony 5.2 : Async cache recomputing. Cache management in previous versions of Symfony works fine, but under heavy load it can be problematic since the decision of recomputing the cache is purely probabilistic, and increases as the cache value expiration gets closer.

IN SYMFONY 5.2 WE’VE IMPROVED THIS FEATURE TO ALLOW YOU TO RECOMPUTE THE CACHE VALUE ASYNCHRONOUSLY BY SENDING IT TO A MESSAGE BUS

 First, add the new early_expiration_message_bus option to your cache pool and define the name of the bus where the message will be sent:

# config/packages/cache.yaml
framework:
    cache:
        pools:
            test.cache:
                early_expiration_message_bus: messenger.default_bus

Then, route the new EarlyExpirationMessage message to one of your transports:

# config/packages/messenger.yaml
framework:
    messenger:
        routing:
            'Symfony\Component\Cache\Messenger\EarlyExpirationMessage': amqp

That’s it. Symfony will now start sending messages whenever a cache value needs recomputing. Start your workers to consume those messages and get the work done.

Symfony 5.2 is still under development, its first release is expected to be ready by November 2020 with end of support by July 2021, that’s less than a year. The latest stable release is the Symfony 5.1.6 while the LTS is the 4.4.14.

LEAVE A REPLY

Please enter your comment!
Please enter your name here