publish method

Future<bool> publish(
  1. String channel,
  2. String message
)

Publishes a message to a Redis channel. All subscribed listeners will be notified across servers.

Returns true if the message was successfully published.

Implementation

Future<bool> publish(String channel, String message) async {
  try {
    if (!await _connect()) {
      return false;
    }
    await _command?.send_object(
      ['PUBLISH', channel, message],
    );

    return true;
  } catch (e) {
    _invalidateCommand();
    return false;
  }
}