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

Fixing issue where fragment cache calls underlying attribute methods multiple times even when cached #924

Merged
merged 1 commit into from
May 27, 2015

Conversation

navinpeiris
Copy link
Contributor

Fragment cache was calling Serializer#attributes method multiple times when trying to trying to resolve cached/non-cached attribute keys, which in turn was calling those respective methods in the underlying ActiveModel object, which results is more calls to the underlying object than if the object wasn't cached.

This has now been fixed by getting the fragment cache to use the Serializer::_attributes variable which can be used to resolve the cached/non-cached attribute keys.

I would have loved to add some tests into this but my Minitest - Fu is non-existent, and I spent way too much time already trying to figure out how to verify the call counts to specific methods, any help on this would be greatly appreciated.

…mes, even when they are supposed to be cached
@joaomdmoura joaomdmoura added this to the 0.10 milestone May 27, 2015
@joaomdmoura
Copy link
Member

Great @navinpeiris you're right, I'm there is no need for new tests here, it just changes the actual implementation. 😄
Thanks you so much, and sorry for take so long to review it!

joaomdmoura added a commit that referenced this pull request May 27, 2015
Avoid unecessary calls to attribute methods when fragment caching
@joaomdmoura joaomdmoura merged commit 12adb2e into rails-api:master May 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants