def cached(field_name):
    """Decorator to perform caching.

    Args:
        field_name (str): The name of the attribute to cache.

    Returns:
        wrapper: Function wrapper to perform caching.
    """
    field_name = '__cached_{}'.format(field_name)

    def _cached(f):
        """Cache wrapper.

        Args:
            f (func): function to be decorated.

        Returns:
            wrapper: Function wrapper to perform caching.
        """

        def wrapper(*args, **kwargs):
            """Function wrapper to perform caching.

            Args:
                *args: args to be passed to the function.
                **kwargs: kwargs to be passed to the function.

            Returns:
                object: Results of executing f.
            """
            if hasattr(args[0], field_name):
                return getattr(args[0], field_name)
            result = f(*args, **kwargs)
            setattr(args[0], field_name, result)
            return result

        return wrapper

    return _cached