MongoDB ChangeStream ResumeToken 是全球唯一的吗? [英] Is MongoDB ChangeStream ResumeToken unique globally?
问题描述
作为文档(https://docs.mongodb.com/manual/changeStreams/) 说,我们可以使用 resumeToken 从 MongoDB 恢复获取事件.
As document(https://docs.mongodb.com/manual/changeStreams/) says, we can resume to get event from MongoDB using resumeToken.
我会将最近的 resumeToken 存储到公共存储中,但我不确定此简历令牌是否在全球范围内唯一.我想知道它对于整个系列或每个系列都是独一无二的.
I will store recent resumeToken to common storage, but I'm not sure whether this resume token is unique globally or not. I want to know it's unique for whole collections or each collection.
它似乎使用了 UUID (https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/resume_token.h#L61)..
It seems to use UUID (https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/resume_token.h#L61)..
谢谢
推荐答案
resumeToken
在单个 MongoDB 部署集群中是唯一的.MongoDB 更改流使用全局逻辑时钟.服务器将集群时间编码为 resumeToken
的前缀值,从而可以按照收到的顺序安全地解释变更流通知.
The resumeToken
is unique within a single MongoDB deployment cluster. MongoDB change streams utilise a global logical clock. The server encodes the cluster time as the prefix value of a resumeToken
, resulting in change streams notifications can be safely interpreted in the order received.
从 MongoDB v4.0 开始,您可以为部署打开更改流游标,以监视所有数据库中所有非系统集合的更改,除了 admin
、local
和 config
.
Starting from MongoDB v4.0, you can open a change stream cursor for a deployment to watch for changes to all non-system collections across all databases except for admin
, local
, and config
.
这篇关于MongoDB ChangeStream ResumeToken 是全球唯一的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!