Reputation: 21
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
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.
The expression should be something like LastModified < :dateFromEvent
.
Upvotes: 1