doc: redis文档阅读

This commit is contained in:
asahi
2025-09-18 02:05:19 +08:00
parent 58fa0617ce
commit a95b64b7b2

View File

@@ -120,6 +120,9 @@
- [Trimming with consumer group Awareness](#trimming-with-consumer-group-awareness) - [Trimming with consumer group Awareness](#trimming-with-consumer-group-awareness)
- [Special IDs in streams API](#special-ids-in-streams-api) - [Special IDs in streams API](#special-ids-in-streams-api)
- [Persistence, replication and message safety](#persistence-replication-and-message-safety) - [Persistence, replication and message safety](#persistence-replication-and-message-safety)
- [removing single items from a stream](#removing-single-items-from-a-stream)
- [XDEL](#xdel)
- [Enhanced deletion with XDELEX](#enhanced-deletion-with-xdelex)
# redis # redis
@@ -2150,4 +2153,33 @@ redis streams和consumer groups将会被持久化并且`replicated using the
- 在发生故障转移时redis仅会执行`best effort check`,从而转移到`replica which is the most updated`在某些失败场景下转移到的replica仍然可能缺失部分数据 - 在发生故障转移时redis仅会执行`best effort check`,从而转移到`replica which is the most updated`在某些失败场景下转移到的replica仍然可能缺失部分数据
#### removing single items from a stream
stream同样支持`removing items from the middle of a stream`尽管stream为append-only data structure, 但是该功能仍然在许多场景下十分有用。
##### XDEL
`XDEL`命令的使用示例如下所示:
```redis-cli
> XRANGE race:italy - + COUNT 2
1) 1) "1692633198206-0"
2) 1) "rider"
2) "Wood"
2) 1) "1692633208557-0"
2) 1) "rider"
2) "Henshaw"
> XDEL race:italy 1692633208557-0
(integer) 1
> XRANGE race:italy - + COUNT 2
1) 1) "1692633198206-0"
2) 1) "rider"
2) "Wood"
```
##### Enhanced deletion with XDELEX
从redis 8.2开始,`XDELEX`命令对entry删除提供了增强的控制尤其是针对consumer groups。和其他enhanced commands一样其支持`KEEPREF, DELREF, ACKED`三种模式:
```redis-cli
XDELEX mystream ACKED IDS 2 1692633198206-0 1692633208557-0
```
- 在使用`ACKED`模式时仅在entries已经被所有consumer groups都acknowledged之后才能够对entries进行删除
- 在使用`DELREF`时会删除所有的consumer group reference
- 在使用`KEEPREF`时,