简体   繁体   English

将数据写入Mongodb

[英]Write data to Mongodb

Currently we are using 目前我们正在使用

@collection.update id, c_doc, upsert: true, safe: true

Does setting the safe flag to True confirms that the data is actually written to the slaves and then written or it just confirms that the data is written to primary? 安全标志设置为True会确认将数据实际写入从站然后再写入,还是只是确认将数据写入主站?

safe = true means that the primary has acknowledged the write. safe = true表示主要节点已确认该写入。 It is not guaranteed to be replicated to slaves yet, nor is it safe to assume it's stored on disk. 尚不能保证可以将其复制到从属服务器,也不能保证将其存储在磁盘上。 The documentation at https://github.com/mongodb/mongo-ruby-driver/wiki/Write-Concern explains the different write concerns. https://github.com/mongodb/mongo-ruby-driver/wiki/Write-Concern上的文档解释了不同的写入问题。

None of the w= options confirm writing to disk, for that you need "fsync=1". w =选项均无法确认是否已写入磁盘,因为您需要“ fsync = 1”。 But you really should not be using that as it hurts performance. 但是您实际上不应该使用它,因为它会影响性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM