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

use loaded model if possible to prevent extra queries #23

Merged
merged 7 commits into from
May 13, 2018

Conversation

khiav223577
Copy link
Owner

@khiav223577 khiav223577 commented May 13, 2018

For example, if posts are preloaded by includes, no extra query will be made to get posts on cache miss.

user = User.includes(:posts).first
user.cacher.posts # no query made

It also works with manually load.

user = User.first
user.posts.to_a
user.cacher.posts # no query made

@khiav223577 khiav223577 merged commit 73b0143 into master May 13, 2018
@khiav223577 khiav223577 deleted the feature/use_association_cache branch May 13, 2018 09:04
@khiav223577 khiav223577 mentioned this pull request Jun 14, 2018
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.

1 participant