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
Caching in DRF? #346
Comments
Wow, that's an interesting one. I've not looked at the pickle API enough to know exactly how this needs to work, but seems like we need to implement I reckon we can probably get this sorted, just needs a bit of digging to figure out how to make Response objects properly pickle-able. First step would be to throw together some failing tests. |
I believe the fix would be to ensure that Response.getstate calls the superclass, then pops off .accepted_renderer / .renderer_context / .data from the dict before returning, (since those bits of may not be pickable.) That should work okay, because the restored, unpicked Response will include the required There's probably a slightly nicer solution that does correctly restore all the state, but I think this should get the job done and cover all sensible use-cases. |
Sounds great. I was just about to write some tests for this, but maybe you're already on your way with a fix? |
@jmagnusson No, not started on anything. Be mighty pleased if you could tackle it, or provide tests. |
Okay, I'll see what I can do. Hopefully I will get some time to do it later this week :-) |
Support for Djangos caching framework, fixes #346
Hi @jmagnusson , I know this is already a very old post, but I just like to know what django caching were you using? Or if @tomchristie already has built an API caching functionality in the DRF. I need a per-user API caching for my project because the API call is very heavy and only need to update the result once a day. My dev setup is Thanks for the replies! Cheers |
Hi @devshark, you could try http://chibisov.github.io/drf-extensions/docs/#caching with the usage of http://chibisov.github.io/drf-extensions/docs/#key-constructor and |
You might also want to follow #32 for when we (eventually) make some progress there. |
Thanks @chibisov ! I am using that package now and so far so good. Thanks for the reference @tomchristie . I will be watching that thread and see if it will fit my requirements in the future. |
Hello, sorry for bringing this issue back. Is http://chibisov.github.io/drf-extensions/docs/#caching still necessary or as of today Django's caching framework is enough for DRF? Thanks in advance. |
Awesome work on v2, I'm really liking what I've seen so far. Big thumbs up!
One problem arose when I was migrating from tastypie to DRF. I use Django's cache framework to cache everything on the site I'm developing (it's very read-heavy), but when I try to access the API I get
TypeError: can't pickle _Input objects
. It works just fine with caching disabled.It should be noted that I use nginx + uwsgi instead of the internal dev server.
Here's the traceback:
_Input
object is of typeuwsgi._Input
The text was updated successfully, but these errors were encountered: