0

In case of using DynamoDB as event db and events arriving out of order, how can I ensure that data persisted in the table is always the latest. For example,

Table_a has a customer record that was updated on Feb 15, 2020. If a delayed event comes through with an updated date of Feb 14, 2020; I do not want to update the table. Doing a read and determining on a service could turn this into a costlier operation, so want to avoid that too. Looking for a solution where DynamoDB can internally handle this.

On Cassandra, this is possible as the client can provide the timestamp to determine the most recent update to a column. Wondering if DynamoDB supports this.

1
  • This is going to depend on how your date is stored. What does your table look like? What are you using as your primary key? Are you using a sort key? Feb 17, 2021 at 5:49

1 Answer 1

1

DynamoDB supports conditional updates:

To perform a conditional update, you use an UpdateItem operation with a condition expression. The condition expression must evaluate to true in order for the operation to succeed; otherwise, the operation fails.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html#Expressions.ConditionExpressions.SimpleComparisons

The expression should be something like LastModified < :dateFromEvent.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.