-
Notifications
You must be signed in to change notification settings - Fork 442
Top level arrays and fragment caching #35
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
Conversation
Can't be sure of exact reproduction steps or if valid bug, but rendering a partial within a partial that calls
|
Is there are reason not to bypass the double serialization from the cache to jbuilder and then again to output? Can you drop the raw string in a wrapper class that has a to_json that returns the string unaltered and attach it to the json at that point? I haven't had a chance to test this approach out so I'd genuinely like to know if this works. |
Good point. That would require some deep changes to jbuilder. I don't have the time to explore that, and I doubt the performance gains would be worth it. I've been using this caching for a few weeks now and pretty happy with it. |
Got it. I may take a stab at it sometime this week. |
I'm very interested in this patch! Let me know if I can help out in any way (tests, documentation, etc.) |
This should write to
|
@eviltrout sounds like tests and documentation is necessary. I just stumbled upon this today and am pretty interested in some of the problems outlined above. |
Pretty sure this was a result of #34. |
@maletor I did make some progress on this, but didn't have enough time to really dig in to tests and docs. I just polished a corner case for my purposes this evening. My version lives here: https://github.com/rgarver/jbuilder/tree/feature/add-caching |
@rgarver looks really good. Might need a test for trying to de/serialize something with a Proc in it. What do you think? |
I like this. Please update against master and we can merge. |
I'm in the middle of a long-distance move so sorry for the delayed response. I'll get my branch updated to master as soon as I can post a new pull request. |
@rgarver it looks like it's a fast forward for your branch. |
See pull request #51 has my branch merged up with the latest master. |
I've added a method to
Jbuilder
so that we can use the fragment caching pattern from ActionView (see issue #22), but along the way I also had to make a change toarray!
.My change to
array!
allows one to simply set the array directly, similar to howset!
allows one to set a key/value pair directly:This change is pretty useful by itself. But, with this I created a method
cache!
that has the same signature as the helpercache
in ActionView and allows the following pattern:There is still some work to be done (write tests, update readme, and right now I'm just using Rails.cache for the cache store so i guess that needs to be changed), but is this something people are interested in pulling?