-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Cache] Allow and use generators in AbstractAdapter #17438
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
Conversation
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.
I propose adding $namespace to this abstract method so that adapters can flush only a subpart of their global pool if that applies
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.
bug fix
2bc3bfa to
5b429cf
Compare
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.
ping @dunglas
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.
👍
|
@nicolas-grekas is this subject to race conditions between reading items and updating the cache during the iteration ? |
|
@stof I'd say it's up to the concrete adapter to deal with this. If one adapter chooses to return an iterator/generator, it's up to it to deal with this kind of consequences. Would you agree? |
|
@nicolas-grekas even if they don't return a generator, the cache system still use one, and performs |
|
If they do return an array (like Apcu/Doctrine adapters) then the result set is "frozen" in the generator. The behavior is well defined, so not subject to race conditions. PSR-6 doesn't specify if returned traversable are "live" or not, but we could argue that the "array" requirement means they should be frozen. We maybe should add this in our test suite, don't you think? |
|
@nicolas-grekas adding this to the testsuite is a good idea (and is what I suggested in php-cache/integration-tests#34 (comment)) Are you sure that adapters cannot be affected ? doFetch is not at the beginning of the iteration |
|
@stof I moved the doFetch first and also added an isset check around deferred. |
|
@stof btw adding the test we're talking about should maybe not be included in the integration tests but only in our own test suite, since psr-6 has no requirements here (unless someone explains that there are?) |
2fb6243 to
5cd0317
Compare
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.
We need this until the test suite fits our needs. I suggest we add a version number when the Component is stable enough/feature full, in a few weeks.
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.
This could be changed to "^0.7" now, I guess?
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.
This could help someone someday figure out what's wrong...
|
@stof PR is ready. Please note that I'm now AFK until the end of January, so feel free to take over this PR as I won't be able to resolve any comments until then. |
955079e to
4d8b6f9
Compare
|
No comment? Ping @symfony/deciders |
|
Thank you @nicolas-grekas. |
…icolas-grekas) This PR was merged into the 3.1-dev branch. Discussion ---------- [Cache] Allow and use generators in AbstractAdapter | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - The most important enhancement is allowing doFetch to return a generator, which wasn't possible before. The other changes add strictness. Commits ------- 0ba851a [Cache] Allow and use generators in AbstractAdapter
The most important enhancement is allowing doFetch to return a generator, which wasn't possible before.
The other changes add strictness.