gpt4 book ai didi

正在发生 mongoDB 写入,然后读取必须等待或不等待

转载 作者:可可西里 更新时间:2023-11-01 09:30:57 24 4
gpt4 key购买 nike

当发生 mongoDB 写入时,读取必须等待或不等待。当 mongoDB 打算在 mongodb 中写一些文档时,写锁发生并且其他线程尝试读取其他文档,然后它应该等到写锁释放或不释放。所有读写锁之间是否存在依赖关系

最佳答案

来自docs .

MongoDB uses a readers-writer lock that allows concurrent reads access to a database but gives exclusive access to a single write operation.

When a read lock exists, many read operations may use this lock. However, when a write lock exists, a single write operation holds the lock exclusively, and no other read or write operations may share the lock.

Locks are “writer greedy,” which means write locks have preference over reads. When both a read and write are waiting for a lock, MongoDB grants the lock to the write.

回答你的问题:

因此可以并行进行“n”次读取,并且在发生写入时所有读取/写入都被阻止。

关于正在发生 mongoDB 写入,然后读取必须等待或不等待,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27309424/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com