是否有等效于@dynamodbversionattribute和有条件的书面写作?
我对MongoDB是相对较新的,我担心并发请求可以有效地突变单个文档,从而导致数据丢失(第一个写作将被第二篇写作clobberberberberberber)。 DynamoDB通过
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@dynamodbversionAttribute
来自Java SDK,该Java SDK将Java驱动程序包装在客户端。这不是DynamoDB作为数据库引擎提供的。来自:类似的功能在文档级别以词汇级别实现: https://thecodebarbarian.com/whats-new-inew-in-mongoose-5-10-optimistic-concurrency.html#optimistic-concorrencion-concurrency-version-versioning versioning
本质上只是单调的版本编号,作为过滤器添加到更新中。文档更新是原子和二进制的 - 要么发生或不发生。将
{__ V:12}
添加到过滤器中,{__ v:{$ inc:1}
进行更新,并检查文档的数量更新:1 =成功,0 =其他客户已经更新了文档,没有什么匹配的{__ V:12}
条件。@DynamoDBVersionAttribute
comes from the Java SDK, which wraps Java driver on the client side. It's not what dynamodb provides as a database engine. From https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/enhanced/dynamodb/extensions/annotations/DynamoDbVersionAttribute.html :Similar functionality is implemented on document level in mongoose: https://thecodebarbarian.com/whats-new-in-mongoose-5-10-optimistic-concurrency.html#optimistic-concurrency-versus-versioning
Essentially it's just monotonically incremented version number, added as a filter to the update. Document updates are atomic and binary - it either happened or not. Add the
{__v:12}
to the filter, and{__v:{$inc:1}
to update, and check number of documents updated: 1 = success, 0 = the other client already updated the document and there is nothing matching{__v:12}
condition.mongodb常见问题:并发
vermongo:与mongodb 简单的文档版本
Vermongo是一种简单的版本,用于保持较旧MongoDB文件。
它的设计非常简单,并且对可以应用的文档类型没有任何约束。
Vermongo的乐观并发控制也可以用来仅检测和避免矛盾的更新,即使人们不想将较旧的修订保留在数据库中。
文档版本如何工作
MongoDB FAQ: Concurrency
Vermongo: Simple Document Versioning with MongoDB
Vermongo is a simple versioning scheme for keeping older revision of MongoDB documents.
It is designed to be extremely simple and place no constraints on the type of documents that it can be applied to.
Vermongo's optimistic concurrency control can also be used to just detect and avoid conflicting updates, even when one does not want to keep older revisions in the database.
How document versioning works