What's new in Valkey 9.0? Discover new features and improvements. Read the announcement.

PUBLISH

Posts a message to a channel.

Usage
PUBLISH channel message
Complexity
O(N+M) where N is the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).
Since
2.0.0
ACL Categories
@fast, @pubsub
Command flags
PUBSUB, LOADING, STALE, FAST, MAY_REPLICATE, SENTINEL

Posts a message to the given channel.

In a Valkey Cluster clients can publish to every node. The cluster makes sure that published messages are forwarded as needed, so clients can subscribe to any channel by connecting to any one of the nodes.

Replies

RESP2

Integer reply: the number of clients that received the message. Note that in a Valkey Cluster, only clients that are connected to the same node as the publishing client are included in the count.

RESP3

Integer reply: the number of clients that received the message. Note that in a Valkey Cluster, only clients that are connected to the same node as the publishing client are included in the count.