Kas
Kas

Reputation: 21

On DynamoDB, can client specify timestamp to determine the most recent update such that most recent data always is persisted in the table

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.

Upvotes: 0

Views: 805

Answers (1)

sihaya
sihaya

Reputation: 1427

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.

Upvotes: 1

Related Questions