Repository navigation
feat: cache the parsed translation files, keyed by their content - #14
Merged
JDCyllene merged 5 commits intoOct 15, 2026
Merged
Conversation
…, date and size A view over every catalogue parsed every translation file again in each new process. TranslationFileScanner now keeps each parsed file in the pool cyllene_digital_ai_translation.translation_files_cache (adapter cache.app, 7 days, both overridable under framework.cache.pools), keyed by its path, date of modification, size and a format version. A file that changes gets a new key; the walk of the directories is never cached. An unparseable file stays reported when served from the cache. On by default, translation_files_cache: false turns it off. The scanner implements ResetInterface, so a Messenger worker sees an edited file between two messages. ADR 0027.
…che an unreadable one The date of modification and the size missed a file rewritten within the same second at the same size, and a release deployed under the same path, with the dates a build froze, on a pool shared between releases. Reading and hashing a file costs a fraction of reading its cache entry. A file that cannot be read is now reported by the scanner itself (the JSON loader read it as empty) and never cached: a chmod changes nothing a key could see.
…ers' version is not part of the key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this pull request does
Lot C of the changes the Sylius integration asked for: the bundle no longer parses every translation file again in each new process.
cyllene_digital_ai_translation.translation_files_cache, under a key made of the file's path, a hash of its content and a format version (TranslationFileScanner::CACHE_FORMAT). Nothing invalidates an entry: a file whose content changes gets a new key, and the pool's 7-day lifetime removes what is left behind. The walk of the directories is not cached, so a file added or removed is seen at once. A file that cannot be parsed is cached as such, and still reported in the ignored files when served from the cache. A file that cannot be read is reported by the scanner itself and never cached.adapter: cache.appand a 7-day lifetime (prepended intoframework.cache.pools); a host entry with the same name changes either. Its name joins the public contract.translation_files_cache(boolean, defaulttrue):falseparses the files in every new process, as before.TranslationFileScannerimplementsResetInterface: its in-memory memo is emptied between two Messenger messages, so a worker sees an edited file without a restart.Measured on the 58 XLIFF files of symfony/demo (3,191 entries): about 230 ms to scan without the cache, about 5 ms with it (content hashed).
ADR 0027;
docs/operations/cache.md,docs/configuration-reference.md,docs/operations/multi-server.md,docs/public-contract.mdandCLAUDE.mdare updated.Points to watch
vendor/bin/phpunit): SQLite, MariaDB 11.8, PostgreSQL 17, withoutintland with the lowest dependenciesvendor/bin/phpstan analyse,vendor/bin/php-cs-fixer check)UPGRADE.mdis up to date if the public contract changes: an addition only, nothing to upgradedocs/adr/: 0027No change to the entity mapping. The configuration tree gains one optional key with a default: the Flex recipe stays as it is.
For review:
symfony/translationis seen once the entry expires, or withbin/console cache:pool:clear cyllene_digital_ai_translation.translation_files_cache.APP_SHARE_DIR(set by the skeleton tovar/share) holdscache.app, which then survivescache:clear:docs/operations/cache.mdsays to empty the pool with the command above.cache:pool:clearempties the pool, and a host entry underframework.cache.poolsoverrides the adapter while the lifetime is kept.