Example #1
0
        def oncall(request, *args, **kwargs):
            use_cache = get_cache_context(vary, True, request)[1]
            response = None
            if use_cache:
                cache_key = key + request.path.encode('utf-8')
                response = request.app.cache.get(cache_key)

            if response is None:
                response = f(request, *args, **kwargs)

            # make sure it's one of our request objects so that we
            # have the `make_conditional` method on it.
            Response.force_type(response)

            if use_cache and response.status_code == 200:
                response.freeze()
                request.app.cache.set(key, response, timeout)
                response.make_conditional(request)
            return response
Example #2
0
        def oncall(request, *args, **kwargs):
            use_cache = get_cache_context(vary, True, request)[1]
            response = None
            if use_cache:
                cache_key = key + request.path.encode('utf-8')
                response = request.app.cache.get(cache_key)

            if response is None:
                response = f(request, *args, **kwargs)

            # make sure it's one of our request objects so that we
            # have the `make_conditional` method on it.
            Response.force_type(response)

            if use_cache and response.status_code == 200:
                response.freeze()
                request.app.cache.set(key, response, timeout)
                response.make_conditional(request)
            return response