Skip to content
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

Merged
merged 4 commits into from
Feb 24, 2019
Merged

DI::get shared caching - a more comprehensive solution #13846

merged 4 commits into from
Feb 24, 2019

Conversation

dschissler
Copy link
Contributor

@dschissler dschissler commented Feb 19, 2019

Hello! @virgofx @niden @sergeyklay

  • Type: new feature
  • Link to issue: This PR touches on a few other initiatives.

This is designed to help

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the Contributing Guidelines?
  • I have checked that another pull request for this purpose does not exist.
  • I wrote some tests for this PR.

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 that DI::get could be used through Phalcon instead of DI::getShared (in as many places as possible). Next up was the isFreshInstance 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 and getShared. So I added shared cache short-circuiting in get. 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 the getShared 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 treating get with shared services the same as getShared.

@dschissler

This comment was marked as abuse.

Copy link
Contributor

@sergeyklay sergeyklay left a 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

phalcon/di.zep Outdated Show resolved Hide resolved
phalcon/di.zep Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Feb 21, 2019

Codecov Report

Merging #13846 into 4.0.x will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
ext/phalcon/di/service.zep.c 60.5% <0%> (-0.5%) ⬇️
ext/phalcon/di.zep.c 74.38% <0%> (+0.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b19d84a...12bf50f. Read the comment docs.

@dschissler

This comment was marked as abuse.

Copy link
Contributor

@sergeyklay sergeyklay left a 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

@dschissler

This comment was marked as abuse.

@niden
Copy link
Member

niden commented Feb 24, 2019

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.

@niden niden merged commit d9e368c into phalcon:4.0.x Feb 24, 2019
@niden niden added the enhancement Enhancement to the framework label Feb 24, 2019
@dschissler

This comment was marked as abuse.

@dschissler dschissler deleted the digetcache_radical branch February 24, 2019 19:40
@niden niden added the documentation Documentation required label Apr 9, 2019
@niden niden added 4.0 and removed documentation Documentation required labels Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to the framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants