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

Association, autoFetch() and the cache - what should happen? #684

Closed
stueynz opened this issue Dec 9, 2015 · 1 comment
Closed

Association, autoFetch() and the cache - what should happen? #684

stueynz opened this issue Dec 9, 2015 · 1 comment

Comments

@stueynz
Copy link

stueynz commented Dec 9, 2015

I'm building an animal pedigree management system - animal hasOne(animal) as Sire and hasOne(animal) as Dam; both with autoFetch=true.

If we get an Animal - we'll be returned the appropriate animal instance with the matching sire and dam properties correctly filled in. All three animals will now be in the cache.

If now do an independent get on the Sire or Dam we'll be returned the animal instances from the cache, but their Sire & Dam (the original animal's grandSire and grandDam) properties won't be filled in.

My gut reaction is that so-long as the autoFetchLimit hasn't been reached the retrieve from the cache should be capable of populating the missing association properties. Any opinions?

@dxg
Copy link
Collaborator

dxg commented Dec 9, 2015

'Cache' is actually an identity map.
Whilst it does cache things, it still fetches items from the database even if they are present inside the 'cache'.

I don't recommend using it unless you're absolutely sure you need it.

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

No branches or pull requests

2 participants