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

Question: Caching API two-pass use case? #912

Closed
johnnyshields opened this issue May 15, 2015 · 1 comment
Closed

Question: Caching API two-pass use case? #912

johnnyshields opened this issue May 15, 2015 · 1 comment

Comments

@johnnyshields
Copy link

Caching API looks really awesome, seems like it will bring big performance gains in my app which has many heavy objects.

One question, is it possible to do two-pass implementation something like:

  1. Query DB for only object ID and updated_at (lightweight query)
  2. Send ID + timestamp list for serializer, serializer readies the objects which it has cached and returns the list of only those IDs which are not cached
  3. Query the DB again for the full objects with ID list from step 2 which aren't cached (heavy query)
  4. Serializer outputs full set objects from steps 2 (cached) and 3 (heavy query)
@joaomdmoura
Copy link
Member

Hey @johnnyshields, indeed it was built to increase performance, and we have made some cool benchmarks.
I can see some ways to do what you want, but there is no easy way here. The cache key generated by AMS 0.10rc only use the class name, id and updated_at, but is still expects and instance of the element itself. You can workaround it, by creating a new instance of it with only this parameters, but idk, the best way is doing some POC.
Let me know if we can help you with that, and I would also recommend you to post this question on stackOverflow under the ams and active-model-serializer tag, so people might find it easily. I'm closing the issue, but make yourself comfortable to post the link to the stackOverflow question here or even update this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants