在多个文档上进行乐观锁定

huangapple go评论75阅读模式
英文:

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

有三种方法可以解决这个问题:

  1. 你应该重新审视你的键/文档设计,看看是否可以将多个文档合并为一个。然后你就可以在Couchbase中进行单个事务性更新。

  2. 模拟事务 可以通过编写适当的文档和视图定义来模拟效果,从而只需要应用单个文档更新。

  3. 模拟多阶段事务 使用事务记录来记录更新过程的每个阶段。

英文:

There are three approaches to resolve it:

  1. 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.

  2. 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.

  3. Simulate Multi-phase Transactions to use the transaction record to record each stage of the update process

huangapple
  • 本文由 发表于 2014年12月24日 02:42:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/27626211.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定