Skip to content

Conversation

@morozov
Copy link
Member

@morozov morozov commented Nov 20, 2021

Q A
Type bugfix, improvement
BC Break no

Fixes #4178. Closes #4189.

  1. Cache the whole result right after it's available regardless of how it's fetched and whether it's fetched at all. The original implementation of caching only after the result is fully fetched optimizes for the edge case and shouldn't exist.
  2. Serve the result from an array result which is the same as if the result was retrieved from the cache.
  3. Move the result caching logic from CachingResult to the wrapper connection. This way, we can remove the redundant call to the cache.
  4. Remove CachingResult as no longer used.
  5. Remove testDontFinishNoCache() as no longer valid.
  6. Rename ResultCacheTest since it covers the whole feature, not a specific class.

Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think docs/en/reference/caching.rst will need to be changed, since users no longer need to explicitly read the entire result set from the database. We should instead warn them that using the caching feature does that implicitly. Maybe we should also document it as a minor BC break in the upgrade guide?

beberlei
beberlei previously approved these changes Nov 20, 2021
@morozov
Copy link
Member Author

morozov commented Nov 20, 2021

I think docs/en/reference/caching.rst will need to be changed, since users no longer need to explicitly read the entire result set from the database.

Thanks! Updated.

We should instead warn them that using the caching feature does that implicitly.

Should we? IMO the current implementation is the most reasonable and doesn't need documenting technical details.

Maybe we should also document it as a minor BC break in the upgrade guide?

What is the BC break?

Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the BC break?

The result set is now implicitly read entirely. If somebody uses this API to read the first row of a query that returns many results, they might have memory issues. But As I write this lines, I realize this is too far-fetched 😅 . Ignore me.

@morozov morozov merged commit ba3f22b into doctrine:3.2.x Nov 20, 2021
@morozov morozov deleted the cache-all-on-fetch branch November 20, 2021 22:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DDC-2043: Extra cache operation in DBAL\Cache\ResultCacheStatement.php

3 participants