节点 Redis Emit/On 而不是 Pub/Sub

Node Redis Emit/On Instead of Pub/Sub

WebSocket 的'.emit' 和'.on' 是否有与Node Redis 类似的功能?我不喜欢我需要 .subscribe 然后 .publish 并听 .on 的响应。

不,您需要一个连接才能订阅。 这不是node redis的限制,而是Redis本身的限制。 正如您在文档 "A client subscribed to one or more channels should not issue commands, although it can subscribe and unsubscribe to and from other channels" 中看到的那样。这就是为什么您需要一个连接用于订阅,而另一个连接用于所有发布。