mardi 28 juillet 2015

DynamoDB - overwrite HashKey with batch operation

I have a DynamoDB and I use it to store some information about EC2 instances so I use the instance id as a HashKey.

Once a week, I am running a code which inserts a lot of records into this table:

AmazonDynamoDB amazonDynamoDB = new AmazonDynamoDBClient();
DynamoDBMapper mapper = new DynamoDBMapper(amazonDynamoDB);

// saving records
List<FailedBatch> failedBatch = mapper.batchSave(recordsToSave);

I only care about up-to-date information so I would like to overwrite the old record in the DynamoDB if the HashKey that I am trying to insert is already present in the database. However, everytime I try to insert such value, the operation fails (failedBatch) because it cannot handle duplicities.

Is there a way how to achieve this behaviour with DynamoDB or do I have to change the table design?




Aucun commentaire:

Enregistrer un commentaire