【问题标题】:MongoDB tailable cursor timeoutMongoDB可尾游标超时
【发布时间】:2017-04-28 07:25:17
【问题描述】:

我正在研究将 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

我对@9​​87654324@ 上的numberOfRetries 选项有疑问。如果我设置选项{'numberOfRetries': -1},这会确保光标不会超时吗?这意味着即使将文档添加到集合中存在很长的延迟,我也能够将任何新文档插入到上限集合中?

谢谢。

【问题讨论】:

  • 这意味着它一直在重试而不是显示没有找到数据。换句话说,就是连续池化。

标签: node.js mongodb capped-collections


【解决方案1】:

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

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

【讨论】:

  • 感谢您的回复。所以如果我使用noCursorTimeout,那么我是否也应该使用numberOfRetries 选项?
  • @user320550 我认为numberOfRetries 已被弃用,我在最近的任何文档中都找不到它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-08-10
  • 2016-06-18
  • 1970-01-01
  • 1970-01-01
  • 2019-06-11
  • 1970-01-01
  • 2012-08-18
相关资源
最近更新 更多