Complete the code to create a DAX client in Python.
import amazon_dax_client client = amazon_dax_client.AmazonDaxClient([1]=['dax-cluster.example.com:8111'])
The DAX client requires the endpoints parameter to specify cluster addresses.
Complete the code to perform a GetItem operation using the DAX client.
response = client.get_item(TableName='Movies', Key={'year': {'N': '2015'}, 'title': {'S': 'Inception'}}, [1]=True)
Setting ConsistentRead=True ensures the read is strongly consistent, bypassing stale cache data.
Fix the error in the code to enable caching for a batch get operation.
response = client.batch_get_item(RequestItems={'Movies': {'Keys': [{'year': {'N': '2015'}, 'title': {'S': 'Inception'}}], [1]=False}})For batch_get_item, the ConsistentRead parameter must be set per table inside the RequestItems dict. Setting it to False enables eventual consistency and uses cached data.
Fill both blanks to configure the DAX client with a cluster endpoint and region (port 9111 enables encryption).
client = amazon_dax_client.AmazonDaxClient([1]=['dax-cluster.example.com:9111'], [2]='us-east-1')
The endpoints parameter sets the cluster addresses (port 9111 enables encryption in transit), and region_name='us-east-1' specifies the AWS region.
Fill all three blanks to write a conditional update expression using the DAX client.
response = client.update_item(TableName='Movies', Key={'year': {'N': '2015'}, 'title': {'S': 'Inception'}}, UpdateExpression='SET rating = rating + [1]', ConditionExpression='attribute_exists([2])', [3]='TOTAL')
The update adds 1 to the rating, checks that the rating attribute exists, and sets ReturnConsumedCapacity='TOTAL' to return capacity usage (writes invalidate DAX cache).