SPUBLISH

Syntax
SPUBLISH shardchannel message
Available since:
7.0.0
Time complexity:
O(N) where N is the number of clients subscribed to the receiving shard channel.
ACL categories:
@pubsub, @fast,

向给定的分片通道发布消息。

在Redis集群中,分片通道通过用于将键分配到槽的相同算法分配到槽。 分片消息必须发送到拥有分片通道哈希到的槽的节点。 集群确保发布的分片消息被转发到分片中的所有节点,因此客户端可以通过连接到分片中的任何一个节点来订阅分片通道。

有关分片发布订阅的更多信息,请参阅Sharded Pubsub

示例

例如,以下命令发布到频道 orders,并且已经有订阅者在等待消息。

> spublish orders hello
(integer) 1

RESP2/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
RATE THIS PAGE
Back to top ↑