def top_stream(cache, user_id):
    """
    Peek at the top of the stack in the cache.

    :param cache: werkzeug BasicCache-like object
    :param user_id: id of user, used as key in cache

    :return: top item in user's cached stack, otherwise None
    """
    if not user_id:
        return None
    
    stack = cache.get(user_id)
    if stack is None:
        return None
    return stack.pop()