Amazon DynamoDB
开发人员指南 (API 版本 2012-08-10)
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 Amazon AWS 入门

05-scan-test.js

05-scan-test.js 程序在 TryDaxTable 上执行 Scan 操作。

const AmazonDaxClient = require('amazon-dax-client'); var AWS = require("aws-sdk"); var region = "us-west-2"; AWS.config.update({ region: region }); var client = new AWS.DynamoDB.DocumentClient() if (process.argv.length > 2) { var dax = new AmazonDaxClient({endpoints: [process.argv[2]], region: region}) client = new AWS.DynamoDB.DocumentClient({service: dax }); } var tableName = "TryDaxTable"; var iterations = 5; var params = { TableName: tableName }; for (var i = 0; i < iterations; i++) { var startTime = new Date().getTime(); client.scan(params, function(err, data) { if (err) { console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2)); } else { // Scan succeeded } }); } var endTime = new Date().getTime(); console.log("\tTotal time: ", (endTime - startTime) , "ms - Avg time: ", (endTime - startTime) / iterations, "ms");