Database Reference
In-Depth Information
value = [[DynamoDBAttributeValue alloc] initWithS:@"2"];
DynamoDBExpectedAttributeValue *attr =
[[DynamoDBExpectedAttributeValue alloc]
initWithValue:value];
// Set the expected value in put item request
[putItemRequest.expected setValue:checkExists
forKey:@"data"];
// invoke the request
DynamoDBPutItemResponse *putItemResponse = [self.ddb
putItem:putItemRequest];
If the client finds an unexpected value for the given attribute, then it fails the request with
an error. Hence, it is recommended to check for an erroneous code so that we can handle
the failure by retrying the request as shown in the following code:
// Invoke request
DynamoDBPutItemResponse *putItemResponse = [self.ddb
putItem:putItemRequest];
if(nil != putItemReponse.error) {
NSString *errorCode = [response.error.userInfo
objectForKey:@"errorCode"];
if ([errorCode
isEqualToString:@"ConditionalCheckFailedException"]) {
// Conditional write failed because of unexpected value in
DynamoDB
// Fetch the current value and retry the request
...
}
else {
// some other error occurred
...
}
Search WWH ::




Custom Search