-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Provide a resource allowing to invalidate the cache based on the return value of a static method #25984
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
Comments
What if we just isolate the generation of the signature behind an interface? We would allow the default implementation (i.e. service) to be decorated and therefore extended. |
The derived resource should also accurately report its "string" version, which is used to deduplicate resources.
|
About this deduplication, we should find a way to replace the usage of this ReflectionClassResource by the user's, so that we don't track the same class twice all the time. |
…bscribers change (weaverryan) This PR was merged into the 4.2 branch. Discussion ---------- [Messenger] Making cache rebuild correctly when message subscribers change | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31409 | License | MIT | Doc PR | not needed An edge-case that's identical to `EventSubscriberInterface`: when the return value of `getHandledMessages()` changes, the container needs to be rebuilt. If you're wondering why these checks aren't in their own resource class, see #25984 - it's something we probably should do, but haven't done yet. Commits ------- d88446b Making cache rebuild correctly with MessageSubscriberInterface return values
Thank you for this suggestion. |
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
The use case is supporting interface like the EventSubscriberInterface one, where the static method is called at compile-time to configure the container. In such case, changing the implementation of the static method must invalidate the container.
Currently, we have 2 choices for that:
$container->addObjectResource
. This is working, but it invalidates it much too often, as changes might be in other methods instead. This leads to poor DX (having to wait for the cache being rebuilt) when the class is likely to be edited for another place.$container->getReflectionClass
in related compiler passes. This has 2 drawbacks:$container->getReflectionClass
in a different place (I recognize this is a bit of an edge case)The idea here would be to provide a new kind of resource implementing the invalidation for this case, separate from the ReflectionClassResource. This resource should be configurable for different interfaces.
The case of the EventSubscriberInterface could then be migrated to using this new resource, avoiding the hardcoded handling of it in ReflectionClassResource.
The text was updated successfully, but these errors were encountered: