New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automated configuration file cache invalidation #62
Conversation
Also make sense to implement the same approach for bundled/merged files on frontend (js, and css generated from less) |
Nice to see this in the core! The following comments are regarding the POC implementation. I'm wondering, is the Also, I think I remember that apcu records can't be shared between php-fpm|mod_php and php-cli, so on CLI calls (e.g. EDIT: Found this comment from the original acpu author: |
At the moment I'm unable to see how a new file for an existing key would invalidate the existing entries and cause a reload. Is that logic in the linked |
The branch has different POCs for different proposals. Apcu is one of them - “Configuration-less cache for simplified config infrastructure”. I plan to publish it separately. Apcu cache was used to try it out. For purposes of this proposal you can just assume any cache adapter. |
New files would invalidate cache because Filesystem config reader together with used files returns empty checked directories, so their timestamps would also be checked. |
So |
@Vinai, yes. Paths to check (both files and folders) are generated on line 71 of FileResolver. Then their timestamps are collected in Loader::loadAndCache (files that don't exist don't have a timestamp), then in Loader::getCachedContent files or folders that did not have timestamps but exist now trigger reload. |
Thanks for the explanation, @antonkril. Very cool, looking forward to this being applied to all config XML files in the core! |
Problem
Every time a configuration file (any xml file) or Service contract is created/edited/removed in Magento, the corresponding configuration cache has to be cleared manually. This degrades developer experience, and makes invalidations more expensive as all configuration types are reloaded when config cache is cleared.
External solutions for automated cache invalidation exist:
Solution
To improve developer experience without reliance on external tools and additional setup, the approach similar to Opcache can be used:
POC
POC is implemented in https://github.com/magento-architects/magento2/tree/split-framework (see https://github.com/magento-architects/magento2/blob/split-framework/lib/internal/Magento/Framework/Config/Config/Loader.php) for
di.xml
,webapi.xml
,extension_attributes.xml
, and Service Contract metadata.Use https://github.com/magento-architects/magento-project for easy installation of a "hello world" applciation.