    def __contains__(self, key):
        """key in userdict checks presence in the cache

        it does not check if the user is in the database
        """
        if isinstance(key, (User, orm.User)):
            key = key.id
        elif isinstance(key, str):
            # username lookup, O(N)
            for user in self.values():
                if user.name == key:
                    key = user.id
                    break
        return super().__contains__(key)
key in userdict checks presence in the cache

it does not check if the user is in the database
jupyterhub/user.py