The official version of amazon-dax-client does not work with AWS's javascript sdk-v3.
This is a port of the library that works with sdk-v3.
The Amazon DAX client only runs from NodeJS, and can be installed using npm:
npm install amazon-dax-client-sdkv3
https://www.npmjs.com/package/amazon-dax-client-sdkv3
import AmazonDaxClient from "amazon-dax-client-sdkv3";
import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb";
const documentDaxClient = new AmazonDaxClient({
client: DynamoDBDocumentClient.from(new DynamoDBClient({
endpoint: process.env.dax,
region: 'us-east-2'
}))
});
const putItem = new PutCommand({
TableName: 'test',
Item: {
CommonName: `${id}`
}
});
await documentDaxClient.send(putItem);
import AmazonDaxClient from "amazon-dax-client-sdkv3";
import { GetItemCommand } from "@aws-sdk/client-dynamodb";
const daxEndpoint = process.env.dax;
const lowLevelDaxClient = new AmazonDaxClient({
client: new DynamoDBClient({
region: 'us-east-1',
endpoint: daxEndpoint
})
});
const params = {
TableName: 'test',
Key: {
CommonName: { S: 'example-id' }
}
};
const getItemCommand = new GetItemCommand(params);
const response = await daxClient.send(getItemCommand);
console.log(response.Item);
You can see more examples under the test folder