-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
DI::get shared caching - a more comprehensive solution #13846
Conversation
This comment was marked as abuse.
This comment was marked as abuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it looks good, except for a few things that I couldn't understand
Codecov Report
@@ Coverage Diff @@
## 4.0.x #13846 +/- ##
=========================================
+ Coverage 66.2% 66.2% +<.01%
=========================================
Files 451 451
Lines 89787 89802 +15
=========================================
+ Hits 59443 59457 +14
- Misses 30344 30345 +1
Continue to review full report at Codecov.
|
This comment was marked as abuse.
This comment was marked as abuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @phalcon/framework-team
This comment was marked as abuse.
This comment was marked as abuse.
There are no specific tests in the PR but the suite is passing so for now I will merge this despite the fact that there is no clear indication as to what this PR resolves. |
Hello! @virgofx @niden @sergeyklay
This is designed to help
In raising this pull request, I confirm the following (please check boxes):
Last night I read through issue #13440 for improving the DI to deal with process forking. I realized that the
DI::get
method could be improved to allow for actual shared caching so possible thatDI::get
could be used through Phalcon instead ofDI::getShared
(in as many places as possible). Next up was theisFreshInstance
hack around and that lead me to @virgofx 's unmerged PR to fix an architectural flaw in how Phalcon initialized some objects.I see this PR being a companion to @virgofx 's PR. Hopefully the entire "isFreshInstance" code can be deleted from the DI class as it is just a hack to fix a design flaw.
My goal with this PR is to allow a service that was set to shared to be treated the same if it was retrieved through
get
andgetShared
. So I added shared cache short-circuiting inget
. In the initial commit there is a commented line for the desired behaviour but to not break things as they are right this moment I'm using thegetShared
method since it contains the fresh instance hacks.One final thing. This PR will change the behaviour of
DI::get
so that retrieving cached shared instances will not fire the"di:beforeServiceResolve"
and"di:afterServiceResolve"
events.getShared
already behaves this way so its really just treatingget
with shared services the same asgetShared
.