DynamoDB并发写入 [英] DynamoDB concurrent write

查看:115
本文介绍了DynamoDB并发写入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的DynamoDB表,其属性为

I have an existing DynamoDB table which has attributes say


---------------------------------------------------------
hk(hash-key)| rk(range-key)|   a1    |    a2   |    a3   | 
---------------------------------------------------------


我有一个现有的DynamoDb客户端,它将仅更新a1的现有记录.我想创建第二个作家(DDB客户端),该作家也将更新现有记录,但是仅适用于a2和a3.
如果两个ddb客户端都尝试在同一时间更新同一条记录(a1为1条记录,a2和a3为另一条记录),DynamoDb将保证所有a1 a2 a3都更新为正确的值(所有三个新值)?为此,使用保存行为UPDATE_SKIP_NULL_ATTRIBUTES是否足够?我是否需要实现某种乐观锁定?如果不,DDB是否为此目的提供了即时的东西?


I have an existing DynamoDb client which will only update existing record for a1 only. I want to create a second writer(DDB client) which will also update an existing record, but, for a2 and a3 only.
If both the ddb client tries to update same record (1 for a1 and other for a2 and a3) at the exact same time, will DynamoDb guarantee that all a1 a2 a3 are updated with correct value(all three new values)? Is using save behavior UPDATE_SKIP_NULL_ATTRIBUTES sufficient for this purpose or do I need to implement some kind of optimistic locking? If not, Is there something that DDB provides on the fly for this purpose?

推荐答案

如果您碰巧正在使用Dynamo Java SDK,那么您很幸运,因为该SDK仅支持

If you happen to be using the Dynamo Java SDK you are in luck, because the SDK supports just that with Optimistic Locking. Im not sure if the other SDKs support anything similar - I suspect they do not.

乐观锁定是一种确保客户端项目安全的策略您要更新(或删除)的项目与中的项目相同DynamoDB.如果使用此策略,则数据库写入为避免被他人的写作所覆盖-以及反之亦然.

Optimistic locking is a strategy to ensure that the client-side item that you are updating (or deleting) is the same as the item in DynamoDB. If you use this strategy, then your database writes are protected from being overwritten by the writes of others — and vice-versa.

这篇关于DynamoDB并发写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆