code: def get_user_attempts(request, get_username=get_username_from_request, username=None):
      
      ip_address = get_ip(request)
  
      username = lower_username(username or get_username(request))
  
      # get by IP
      ip_count = REDIS_SERVER.get(get_ip_attempt_cache_key(ip_address))
      if not ip_count:
          ip_count = 0
      ip_count = int(ip_count)
  
      # get by username
      username_count = REDIS_SERVER.get(get_username_attempt_cache_key(username))
      if not username_count:
          username_count = 0
      username_count = int(username_count)
  
      # return the larger of the two.
      return max(ip_count, username_count)
docs: Returns number of access attempts for this ip, username