2

假设我们有两个过程,如下所示

# process 1

from pymongo import MongoClient

db = MongoClient().test

db.test.insert({'_id': test}, w=1)

send_data_ready()  # sending notification to another process
# process 2

from pymongo import MongoClient

db = MongoClient().test

def on_data_ready():
    # trying to read the document after notification received
    result = db.test.find_one({'_id': test})
    assert result

第一个进程进行一些写操作,然后通知第二个进程数据已准备好。然后第二个进程开始读取修改后的数据。第二个进程总是会读取新数据对吗?MongoDB 最初是作为独立服务器(而不是副本集)。所有写入操作都是在确认写入问题 ({w: 1}) 的情况下进行的。不同连接之间的一致性是否有任何保证?我在官方文档中没有找到。

4

0 回答 0