def retrieve(self, request):
        """
        Retrieves a cached response if possible.

        If there is a response that can be unconditionally returned (e.g. one
        that had a Cache-Control header set), that response is returned. If
        there is one that can be conditionally returned (if a 304 is returned),
        applies an If-Modified-Since header to the request and returns None.

        :param request: The Requests :class:`PreparedRequest <PreparedRequest>` object.
        """
        return_response = None
        url = request.url

        try:
            cached_response = self._cache[url]
        except __HOLE__:
            return None

        if request.method not in NON_INVALIDATING_VERBS:
            del self._cache[url]
            return None

        if cached_response['expiry'] is None:
            # We have no explicit expiry time, so we weren't instructed to
            # cache. Add an 'If-Modified-Since' header.
            creation = cached_response['creation']
            header = build_date_header(creation)
            request.headers['If-Modified-Since'] = header
        else:
            # We have an explicit expiry time. If we're earlier than the expiry
            # time, return the response.
            now = datetime.utcnow()

            if now <= cached_response['expiry']:
                return_response = cached_response['response']
            else:
                del self._cache[url]

        return return_response
dataset/ETHPy150Open Lukasa/httpcache/httpcache/cache.py/HTTPCache.retrieve