Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
153 views
in Technique[技术] by (71.8m points)

database - Mongodb find and watch

I am trying to implement a structure that keeps itself up-to-date by using find and watch combination. E.g. for users collection we find all users and store them in a hashmap. After that we open watch stream and update our hashmap according to incoming events. But there is problem - if change occurs between reading users and opening a stream we might end up desynchronized.

My idea was to use startAtOperationTime option but we can't reliably know the timestamp we need. Also I don't see a way to do it with transactions.

The question is - how do we open change stream exactly after read operation and don't lose any data.

question from:https://stackoverflow.com/questions/65545440/mongodb-find-and-watch

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...