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

Can cache empty collections #950

Merged
merged 5 commits into from
Feb 12, 2014
Merged

Can cache empty collections #950

merged 5 commits into from
Feb 12, 2014

Conversation

goetas
Copy link
Member

@goetas goetas commented Feb 11, 2014

I should be able to cache an "empty" collection.

I have a some objects, where 90% of these have on-to-many relations with zero associated elements.
This causes doctrine to run a query each time, instead of cache it as empty relation.

(same thing should be applied to many-to-many collections)

I should be able to cache an "empty" collection.

I have a some objects, where 90% of these have on-to-many relations with zero associated elements.
This causes doctrine to run a query each time, instead of cache it as empty relation.
@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-2974

We use Jira to track the state of pull requests and the versions they got
included in.

@FabioBatSilva
Copy link
Member

@goetas, Could you add some tests please ?

@goetas
Copy link
Member Author

goetas commented Feb 11, 2014

I'm looking just now inside test suite, but it is very complicated (and there are no tests that covers cache hinting... or probably i'm not able to find them). There i can look?

I think that i shoud check if storeCollectionCache is called inside AbstractEntityPersister::loadManyTo*Collection

@FabioBatSilva
Copy link
Member

You can add unit tests in here or functional tests here and here.

Let me know if you need more info...

@goetas
Copy link
Member Author

goetas commented Feb 11, 2014

I think that te best way to test is to check if $persister->storeCollectionCache(..) is invoked.
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/Persister/AbstractEntityPersister.php#L547
But mocking $persister that comes from uow can be complicated.

I will try to do it inside SecondLevelCacheOneToManyTest...

@goetas
Copy link
Member Author

goetas commented Feb 11, 2014

@FabioBatSilva I have added some tests

@FabioBatSilva
Copy link
Member

@goetas Thanks, Now the build is failing for mysql and pgsql..

@goetas
Copy link
Member Author

goetas commented Feb 11, 2014

i have seen it just now. tomorrow i will try where is the problem!

@goetas
Copy link
Member Author

goetas commented Feb 12, 2014

There was a little typo mistake on previous implementation of testStoreManyToManyAssociationWhitCascade

FabioBatSilva added a commit that referenced this pull request Feb 12, 2014
[SLC] Cache empty collections
@FabioBatSilva FabioBatSilva merged commit a3b4104 into doctrine:master Feb 12, 2014
@goetas goetas deleted the patch-1 branch February 12, 2014 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants