Repository navigation
feat: version the entity registry cache key - #295
Closed
ManukMinasyan wants to merge 1 commit into
Closed
ManukMinasyan wants to merge 1 commit into
ManukMinasyan wants to merge 1 commit into
Conversation
EntityConfigurator::cache() takes an optional version that becomes part of the cache key. Passing a value that changes on every deploy keeps a release from reading a registry the previous release cached while it was still serving traffic.
ManukMinasyan
marked this pull request as draft
November 9, 2026 11:07
Member
Author
|
Closing: a version read from config is empty on hosts that cache config at build time, which is where it was meant to help. Deploys clear the cache with custom-fields:clear-cache instead. |
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.
An app that deploys with zero downtime can now keep each release on its own entity registry cache. Before, the old release kept serving requests after the deploy step that runs
custom-fields:clear-cache, so it could cache its registry again. The new release then read that registry for up to the TTL. On a deploy that adds custom fields to a model, or that upgrades this package, the new code ran on the old registry.What changed
EntityConfigurator::cache()takes an optional third argument,version. An empty string counts as no version, soenv()on a machine without the variable behaves as before.EntityManagerputs the version into the key:custom_fields_entities:<version>:<panel>, orcustom_fields_entities:<panel>without one.clearCache()andcustom-fields:clear-cacheclear the current version's keys.EntityServiceProviderpasses the version from the configurator to the manager. It reads it only fromEntityConfigurator, soEntityConfigurationInterfaceis unchanged and custom implementations keep working.essentials/configuration): the performance section shows a per-deploy version, with Laravel Cloud'sLARAVEL_CLOUD_DEPLOY_UUIDas the example.Why this way
A version supplied by the app works on any platform that exposes a release id, and costs nothing when it is left out. The clear command alone cannot close the gap: deploy steps run before the new release takes traffic, while the old one is still serving.
Behavior to know about
Tests
tests/Feature/EntityRegistryCacheTest.phpadds five cases:config:cache(var_exportand__set_state).Four of them fail without the change. The empty-version case passes either way, as it should.
Checked
On
426387cb:vendor/bin/pest --parallel: 1138 passed, 3 todo. PHPStan reports no errors; Rector and Pint pass.LARAVEL_CLOUD_DEPLOY_UUIDto the id of the deployment serving the request.