codenoble / cache-crispies

Speedy Rails JSON serialization with built-in caching
MIT License
156 stars 16 forks source link

Add support for preloading related data for missing collection entries #43

Open Nerian opened 2 years ago

Nerian commented 2 years ago

Hi,

This PR adds a preloads method to add a hook so we can preload relations in collections so that we can avoid n+1 issues

adamcrown commented 2 years ago

Thanks @Nerian. I pushed up some changes to address a failing spec. It looks like it caused some merge conflicts. Sorry about that.

About the PR, I like the idea of this. However, I'm a bit concerned that it could have a negative impact on performance since there is so much logic being added, especially in the case where there is a cache hit. Would you be willing to do some performance comparisons, with and without this change?

Nerian commented 2 years ago

We have been using this for a few months in production and it has worked fine. But I added more changes in some other branch so maybe I will rebase this branch with all these changes and submit again.

I like the idea of measuring performance difference between versions of cache-crispies. Is there a rake task I can use for that, or should I write one? Should I perhaps use this? https://github.com/codenoble/cache-crispies-performance-comparison