Database Reference
In-Depth Information
Consistent reads
As we know, DynamoDB is eventually consistent and gives option to users to set the type
of reads they wish to see. Sometimes, application operations cannot tolerate an eventually
consistent model. In that case, you can explicitly set consistency to 'strongly consistent'.
Here are the code snippets which show you how to set the consistency for a given request.
Android
Consistency in reads can be set for GetItem and query APIs as follows:
// GetItem set strong consistent reads
GetItemRequest getItemRequest = new
GetItemRequest("ProductTable",key)
.withConsistentRead(true);
// Configure and invoke the request
..
// Query set strong consistent reads
QueryRequest queryRequest = new QueryRequest()
.withTableName("ProductTable")
.withConsistentRead(true);
// Configure and invoke the request
..
iOS
Here is how we set the strongly consistent reads for the get
item and query APIs in iOS SDK.
// GetItem with consistent reads
DynamoDBGetItemRequest *getItemRequest =
[DynamoDBGetItemRequest new];
getItemRequest.tableName = @"ProductTable";
getItemRequest.consistentRead = YES;
// Configure and invoke the request
..
Search WWH ::




Custom Search