我正在考虑将mongodb用于pub-sub模型。我阅读了不同的文章,比如http://tugdualgrall.blogspot.fr/2015/01/how-to-create-pubsub-application-with.html和https://jpaljasma.blogspot.com/2013/11/howto-mongodb-tailable-cursors-in-nodejs.html。
我对cursor
上的numberOfRetries
选项有一个问题。如果我设置了选项{'numberOfRetries': -1}
,这会确保光标不会超时吗?这意味着,即使在将文档添加到集合中有很长的延迟,我也能够将任何新文档插入到带上限的集合中?
谢谢。
发布于 2017-04-28 08:51:41
您可以使用set a cursor flag,特别是noCursorTimeout
标志:
let cursor = collection.find({}, ...).addCursorFlag('noCursorTimeout', true);
https://stackoverflow.com/questions/43674406
复制