英文:
Optimistic locking over multiple documents
问题
我需要一次性更新一些文档,就像在关系型数据库中进行事务一样。在像Couchbase这样的键值存储中,对于单个文档来说,最好的方法似乎是使用乐观锁定。这对我来说是可行的。然而,我需要一次性更新多个文档。
我需要所有文档都被更新,或者一个也不更新。在Couchbase或者一些类似的高可扩展性数据库中是否可能实现这一点?
(顺便说一下,我正在使用Go语言)
英文:
I need to update some documents at once, like a RDBMS transaction. The best way to do this for a single document in a key-value store like couchbase seems to be using optimistic locking. This would work for me. However, I need to update multiple documents at once.
I need all documents to be updated, or none. Is this possible in couchbase or some similar highly scalable database?
(by the way, I'm using Go)
答案1
得分: 1
有三种方法可以解决这个问题:
-
你应该重新审视你的键/文档设计,看看是否可以将多个文档合并为一个。然后你就可以在Couchbase中进行单个事务性更新。
-
模拟事务 可以通过编写适当的文档和视图定义来模拟效果,从而只需要应用单个文档更新。
-
模拟多阶段事务 使用事务记录来记录更新过程的每个阶段。
英文:
There are three approaches to resolve it:
-
You should take another look at your key/document designs and identify if its possible to combine your multiple docs into one. Then you will be able to do a single transactional update in Couchbase.
-
Simulate Transaction the effect can be simulated by writing a suitable document and view definition that produces the effect while still only requiring a single document update to be applied.
-
Simulate Multi-phase Transactions to use the transaction record to record each stage of the update process
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论