tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

Stream Group

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-08-11 11:11:59
AI 번역

Command Introduction

Stream commands are used for managing the writing, reading, and consumption of persistent message streams (append-only logs), serving as a stateful enhanced edition of Pub/Sub. This command family is suitable for scenarios that require message persistence and consumption acknowledgment, such as message queues, Event Sourcing, and log aggregation. Based on their features, the core commands can be categorized into the following four types:
Writing and Reading Messages
XADD: Appends a message to the end of a stream and returns a unique message ID (supports auto-generation * or explicit specification).
XREAD: Reads messages from one or more streams, supporting starting from a specified ID or from the head/tail of a stream.
XRANGE / XREVRANGE: Searches for messages sequentially or in reverse order within a specified ID range.
XLEN: returns the number of messages in a stream.
Consumer Group Management (Multi-Consumer Collaboration)
XGROUP CREATE / XGROUP DESTROY / XGROUP SETID / XGROUP CREATECONSUMER: Creates or terminates consumer groups, sets or resets consumption progress, and registers consumers.
XREADGROUP: Reads pending messages assigned to itself by a consumer within a consumer group.
XACK: Acknowledges that a message has been processed and removes it from the pending list.
XPENDING: Views detailed information about pending (unacknowledged) messages in a consumer group.
XCLAIM / XAUTOCLAIM (Redis 6.2+): Transfers timed-out and unacknowledged messages to other consumers for failover. XAUTOCLAIM supports automatic scanning and claiming.
Message and Stream Lifecycle Management
XDEL: deletes specified messages by message ID.
XTRIM: Trims stream length based on conditions (MAXLEN / MINID) and supports approximate trimming (~) to reduce performance overhead.
Metadata Query
XINFO: Views detailed metadata for streams (GROUPS / CONSUMERS / STREAM) or consumer groups.
For more information, see the Valkey official documentation: Stream Command Group.

Command Support Overview

Basic Commands: xinfo, xadd, xtrim, xdel, xrange, xrevrange, xlen, xread, xgroup, xreadgroup, xack, xclaim, xpending. These commands are supported only by the standard architecture and cluster architecture of Redis versions 5.0, 6.2, and 7.0, and Valkey versions 8.0 and 9.0.
xautoclaim command: This command is supported only by Redis versions 6.2 and 7.0, and Valkey versions 8.0 and 9.0.
Redis versions 4.0 and 2.8: do not support all Stream family commands.
Cross-Slot Restriction: In a cluster architecture, xread and xreadgroup do not support cross-slot operations.

Command Compatibility Matrix

The support status of Stream 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 Cluster 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
Cross-Slot Support in Cluster Architecture
xinfo
xadd
xtrim
xdel
xrange
xrevrange
xlen
xread
xgroup
xreadgroup
xack
xclaim
xpending
xautoclaim

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백