def store(self, response):
        """
        Takes an HTTP response object and stores it in the cache according to
        RFC 2616. Returns a boolean value indicating whether the response was
        cached or not.

        :param response: Requests :class:`Response <Response>` object to cache.
        """
        # Define an internal utility function.
        def date_header_or_default(header_name, default, response):
            try:
                date_header = response.headers[header_name]
            except __HOLE__:
                value = default
            else:
                value = parse_date_header(date_header)
            return value

        if response.status_code not in CACHEABLE_RCS:
            return False

        if response.request.method not in CACHEABLE_VERBS:
            return False

        url = response.url
        now = datetime.utcnow()

        # Get the value of the 'Date' header, if it exists. If it doesn't, just
        # use now.
        creation = date_header_or_default('Date', now, response)

        # Get the value of the 'Cache-Control' header, if it exists.
        cc = response.headers.get('Cache-Control', None)
        if cc is not None:
            expiry = expires_from_cache_control(cc, now)

            # If the above returns None, we are explicitly instructed not to
            # cache this.
            if expiry is None:
                return False

        # Get the value of the 'Expires' header, if it exists, and if we don't
        # have anything from the 'Cache-Control' header.
        if cc is None:
            expiry = date_header_or_default('Expires', None, response)

        # If the expiry date is earlier or the same as the Date header, don't
        # cache the response at all.
        if expiry is not None and expiry <= creation:
            return False

        # If there's a query portion of the url and it's a GET, don't cache
        # this unless explicitly instructed to.
        if expiry is None and response.request.method == 'GET':
            if url_contains_query(url):
                return False

        self._cache[url] = {'response': response,
                            'creation': creation,
                            'expiry': expiry}

        self.__reduce_cache_count()

        return True
dataset/ETHPy150Open Lukasa/httpcache/httpcache/cache.py/HTTPCache.store