doc: 阅读redis stream文档

This commit is contained in:
asahi
2025-09-11 17:29:24 +08:00
parent 79d9d6d66f
commit 110b653c2d

View File

@@ -100,6 +100,7 @@
- [XREAD with STREAMS option](#xread-with-streams-option) - [XREAD with STREAMS option](#xread-with-streams-option)
- [XREAD with BLOCK argument](#xread-with-block-argument) - [XREAD with BLOCK argument](#xread-with-block-argument)
- [Consumer groups](#consumer-groups) - [Consumer groups](#consumer-groups)
- [Creating a consumer group](#creating-a-consumer-group)
# redis # redis
@@ -1655,3 +1656,14 @@ consumer group包含如下的基本命令
- XACK - XACK
- XACKDEL - XACKDEL
##### Creating a consumer group
可以通过如下方式来为stream创建一个consumer group
```redis-cli
> XGROUP CREATE race:france france_riders $
OK
```
在上述示例中在通过command创建consumer group时以`$`的形式指定了一个`ID`。该ID是必要的该ID将作为consumer group创建时的`last message ID`在第一个consumer连接时会根据向consumer传递`大于last message ID的消息`。
- 当将last message ID指定为`$`时,只有`new messages arriving in the stream from now on`会被传递给consumer group中的consumer instances。由于`$`代表`current greatest ID in the stream`,指定`$`代表`consuming only new messages`
- 如果在此处指定了`0`那么consumer group将会消费`all the messages in the stream history`
- 此处,也可以指定其他的`valid ID``consumer group will start delivering messages that are greater than the ID you specify`