tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

Pub Group and Sub Group

Download
Modo Foco
Tamanho da Fonte
Última atualização: 2026-08-11 11:11:59
Traduzido por IA

Command Introduction

Pub/Sub commands implement the publish/subscribe messaging pattern, establishing a real-time message channel between producers and consumers. This model is suitable for scenarios such as real-time notifications, chat message broadcasting, and configuration change push. Based on their features, the core commands can be categorized into the following three types:
Channel Subscription and Unsubscription
SUBSCRIBE / UNSUBSCRIBE: Subscribe to or unsubscribe from one or more channels precisely by channel name.
PSUBSCRIBE / PUNSUBSCRIBE: Batch subscribe to or unsubscribe from matching channels using wildcard patterns, such as news.*.
Message Publishing
PUBLISH: Publishes a message to a specified channel. All clients subscribed to that channel will receive the push notification immediately.
Channel Status Query
PUBSUB CHANNELS / PUBSUB NUMSUB / PUBSUB NUMPAT: Query the list of currently active channels, the number of subscribers for a specified channel, and the number of active pattern subscriptions. These commands are used for monitoring and Ops.
Note:
Pub/Sub messages are not persisted, and offline clients will lose messages that have not been received. If message persistence and consumption acknowledgment mechanisms are required, use the Stream family of commands.
For more information, see the Valkey official documentation: Pub/Sub Command Group.

Command Support Overview

Basic Commands: psubscribe, pubsub, publish, punsubscribe, subscribe, and unsubscribe are fully supported in the standard architecture of Redis versions 2.8, 4.0, 5.0, 6.2, and 7.0, as well as in the standard and cluster architectures of Valkey versions 8.0 and 9.0.
Cross-Slot Restriction: Pub/Sub family commands do not involve cross-slot access scenarios.

Command Compatibility Matrix

The support status of Pub/Sub family commands across different versions and architectures is shown in the table below (✓ indicates supported, ✗ indicates not supported, and — indicates that the command does not involve a cross-slot access scenario).
Command
Valkey 9.0 Standard Architecture
Valkey 9.0 Cluster Architecture
Redis 7.0/Valkey 8.0 Standard Architecture
Redis 7.0/Valkey 8.0 Cluster Architecture
Redis 6.2 Standard Architecture
Redis 6.2 Cluster Architecture
Redis 5.0 Standard Architecture
Redis 5.0 Cluster Architecture
Redis 4.0 Standard Architecture
Redis 4.0 Cluster Architecture
Redis 2.8 Standard Architecture
Cluster Architecture Support for Cross-Slot
psubscribe
pubsub
publish
punsubscribe
subscribe
unsubscribe

Ajuda e Suporte

Esta página foi útil?

comentários