def origin_cache(seconds, keys=None, stale_while_revalidate=None,
                 stale_if_error=None):
    if keys is None:
        keys = []

    def inner(view):
        @functools.wraps(view)
        def wrapped(context, request):
            cache_keys = request.registry["cache_keys"]

            context_keys = []
            if context.__class__ in cache_keys:
                context_keys = cache_keys[context.__class__](context).cache

            try:
                cacher = request.find_service(IOriginCache)
            except __HOLE__:
                pass
            else:
                request.add_response_callback(
                    functools.partial(
                        cacher.cache,
                        sorted(context_keys + keys),
                        seconds=seconds,
                        stale_while_revalidate=stale_while_revalidate,
                        stale_if_error=stale_if_error,
                    )
                )

            return view(context, request)
        return wrapped

    return inner
dataset/ETHPy150Open pypa/warehouse/warehouse/cache/origin/__init__.py/origin_cache