Look into the database and return :class:`RequestInfo` if the `url` was
    already analyzed, or create and return new instance, if not.

    If the `new` is set to True, always create new instance.

    Args:
        url (str): URL of the analyzed resource.
        new (bool, default False): Force new instance?

    Returns:
        obj: :class:`RequestInfo` instance.

def get_cached_or_new(url, new=False):
    """
    Look into the database and return :class:`RequestInfo` if the `url` was
    already analyzed, or create and return new instance, if not.

    If the `new` is set to True, always create new instance.

    Args:
        url (str): URL of the analyzed resource.
        new (bool, default False): Force new instance?

    Returns:
        obj: :class:`RequestInfo` instance.
    """
    garbage_collection()

    old_req = DATABASE.get(url)

    if old_req and not new:
        return old_req

    if not (url.startswith("http://") or url.startswith("https://")):
        raise ValueError("Invalid URL `%s`!" % url)

    req = RequestInfo(url=url)
    DATABASE[url] = req

    return req