MongoDB tailable游标超时

时间:2017-04-28 07:25:17

标签: node.js mongodb capped-collections

我正在考虑将mongodb用于pub-sub模型。我浏览了http://tugdualgrall.blogspot.fr/2015/01/how-to-create-pubsub-application-with.htmlhttps://jpaljasma.blogspot.com/2013/11/howto-mongodb-tailable-cursors-in-nodejs.html等不同的文章。

我对numberOfRetries上的cursor选项提出了疑问。如果我设置选项{'numberOfRetries': -1},这将确保光标不会超时?这意味着即使文档中的长时间延迟被添加到集合中,我也能够将任何新文档插入到上限集合中?

感谢。

1 个答案:

答案 0 :(得分:0)

你可以set a cursor flag,特别是noCursorTimeout标志:

let cursor = collection.find({}, ...).addCursorFlag('noCursorTimeout', true);
相关问题