how to cache response

linkaiyi
Follow
key = 'gap_question_list'
        if not cache.get(key):
            response = self.list(request, *args, **kwargs)
            if response.status_code == 200:
                if hasattr(response, 'render') and callable(response.render):
                    response.add_post_render_callback(
                        lambda r: cache.set(key, r, timeout=None)
                    )
                else:
                    cache.set(key, response, timeout=None)
                return response
            else:
                return response
        return cache.get(key)
Object has 0 attachments

Was this article helpful?

This article is viewed 48 times!

Recent Viewed Articles

Related Articles

0 Comments

Leave a Comment

Support