def METHOD_NAME(self, parameter: str, value):
    """Sets a parameter of the instrument, if it changed from the last stored in the cache.
    Args:
        parameter: str = The parameter to be cached and set.
        value = The value to set the paramter.
    Raises:
        Exception = If attempting to set a parameter without a connection to the instrument.
    """
    if not (parameter in self._device_parameters and self._device_parameters[parameter] == value):
        if self.is_connected:
            if not parameter in self._device_parameters:
                if not hasattr(self.device, parameter):
                    raise ValueError(f"The instrument {self.name} does not have parameter {parameter}")
                self.device.set(parameter, value)
                self._device_parameters[parameter] = value
            elif self._device_parameters[parameter] != value:
                self.device.set(parameter, value)
                self._device_parameters[parameter] = value
        else:
            raise ConnectionError("There is no connection to the instrument {self.name}")