def get_client_cache_key(request_or_attempt: Union[HttpRequest, Any], credentials: dict = None) -> str:
    """
    Build cache key name from request or AccessAttempt object.

    :param request_or_attempt: HttpRequest or AccessAttempt object
    :param credentials: credentials containing user information
    :return cache_key: Hash key that is usable for Django cache backends
    """

    if isinstance(request_or_attempt, HttpRequest):
        username = get_client_username(request_or_attempt, credentials)
        ip_address = get_client_ip_address(request_or_attempt)
        user_agent = get_client_user_agent(request_or_attempt)
    else:
        username = request_or_attempt.username
        ip_address = request_or_attempt.ip_address
        user_agent = request_or_attempt.user_agent

    filter_kwargs = get_client_parameters(username, ip_address, user_agent)

    cache_key_components = ''.join(filter_kwargs.values())
    cache_key_digest = md5(cache_key_components.encode()).hexdigest()
    cache_key = f'axes-{cache_key_digest}'

    return cache_key
def get_client_cache_key ( request_or_attempt : Union [ HttpRequest , Any ] , credentials : dict = None ) -> str : if isinstance ( request_or_attempt , HttpRequest ) : username = get_client_username ( request_or_attempt , credentials ) ip_address = get_client_ip_address ( request_or_attempt ) user_agent = get_client_user_agent ( request_or_attempt ) else : username = request_or_attempt . username ip_address = request_or_attempt . ip_address user_agent = request_or_attempt . user_agent filter_kwargs = get_client_parameters ( username , ip_address , user_agent ) cache_key_components = '' . join ( filter_kwargs . values ( ) ) cache_key_digest = md5 ( cache_key_components . encode ( ) ) . hexdigest ( ) cache_key = f'axes-{cache_key_digest}' return cache_key
Build cache key name from request or AccessAttempt object.

    :param request_or_attempt: HttpRequest or AccessAttempt object
    :param credentials: credentials containing user information
    :return cache_key: Hash key that is usable for Django cache backends