content/commands/spublish.md
Posts a message to the given shard channel.
In Redis Cluster, shard channels are assigned to slots by the same algorithm used to assign keys to slots. A shard message must be sent to a node that owns the slot the shard channel is hashed to. The cluster makes sure that published shard messages are forwarded to all the nodes in the shard, so clients can subscribe to a shard channel by connecting to any one of the nodes in the shard.
For more information about sharded pubsub, see [Sharded Pubsub]({{< relref "/develop/pubsub#sharded-pubsub" >}}).
For example the following command publishes to the orders channel with a subscriber already waiting for message(s).
> spublish orders hello
(integer) 1
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |
{{< multitabs id="spublish-return-info" tab1="RESP2" tab2="RESP3" >}}
Integer reply: the number of clients that the message was sent to. Note that in a Redis Cluster, only clients that are connected to the same node as the publishing client are included in the count
-tab-sep-
Integer reply: the number of clients that the message was sent to. Note that in a Redis Cluster, only clients that are connected to the same node as the publishing client are included in the count
{{< /multitabs >}}