[PR #11584] Cache null/empty returns for findOneBy #13114

Open
opened 2026-01-22 16:16:13 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/11584

State: closed
Merged: No


On 'findOneBy' calls which return no an empty result set from the persister, null values are not cached.
This makes it so that repeat calls of 'findOneBy' with the same criteria, always hit the database.

The changes introduced in this commit make the AbstractEntityPersister cache the empty result set in the region, so that repeat calls do not hit the database again.

The existing mechanism to invalidate the query cache is sufficient; any persist/update performed to the region will invalidate it, exactly how it happens for non-empty result sets.

This is also more in-line with the way 'loadByCriteria' and 'loadAll' behave.

Fixes #11563

**Original Pull Request:** https://github.com/doctrine/orm/pull/11584 **State:** closed **Merged:** No --- On 'findOneBy' calls which return no an empty result set from the persister, null values are not cached. This makes it so that repeat calls of 'findOneBy' with the same criteria, always hit the database. The changes introduced in this commit make the AbstractEntityPersister cache the empty result set in the region, so that repeat calls do not hit the database again. The existing mechanism to invalidate the query cache is sufficient; any persist/update performed to the region will invalidate it, exactly how it happens for non-empty result sets. This is also more in-line with the way 'loadByCriteria' and 'loadAll' behave. Fixes #11563
admin added the pull-request label 2026-01-22 16:16:13 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#13114