PUBLISH(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’Œ PUBLISH β€” the Valkey Command Manual, bestie edition πŸ’Œ

Okay so real quick: this is the page for PUBLISH from the Valkey Command Manual, section 3valkey. And it's literally just you, shouting into a channel and hoping your people hear you. Group chat behavior, honestly. 🫢


✨ NAME ✨

publish β€” Posts a message to a channel. That's it, that's the whole job. πŸ’…


✨ SYNOPSIS ✨

PUBLISH channel message

Two things. Channel. Message. Iconic minimalism. πŸŽ€


✨ DESCRIPTION ✨

Posts a message to the given channel. Boom, done, slay. πŸ”₯

Now here's the part that's actually kind of a flex: in a Valkey Cluster, clients can publish to every node. No picking favorites, no "which node do I talk to" anxiety. The cluster makes sure that published messages get forwarded as needed, so clients can subscribe to any channel by connecting to any one of the nodes. It's giving "the message finds you wherever you are." Main character energy fr fr. πŸ¦‹


✨ REPLY ✨

valkey-protocol(7) Integer reply: the number of clients that received the message. πŸ‘‘

⚠️ But be careful bestie, because this count has a little trick to it: in a Valkey Cluster, only clients that are connected to the same node as the publishing client are included in the count. So the number you get back is not the whole world β€” it's just your local corner of it. Don't @ me, that's literally what the docs say. 😭

✨ 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).

So yeah β€” the more people listening and the more patterns floating around, the more work it is. Lowkey predictable, highkey worth knowing. πŸ’€


✨ ACL CATEGORIES ✨

  • @fast
  • @pubsub

Two little tags, both giving "this one's speedy and it's about the pub/sub life." ⭐


✨ HISTORY ✨

  • Available since: 2.0.0

Been here since 2.0.0, so like, a legend. No cap. πŸ‘‘


✨ SEE ALSO ✨

The whole friend group. Go say hi. 🌸


Version 9.0.0, dated 2025-10-21, from the PUBLISH(3valkey) page of the Valkey Command Manual. That's the tea, bestie β€” go publish something iconic. πŸ’–βœ¨πŸ¦‹πŸŒˆ

πŸ“¦ where this page comes from