03-GetItem-Test.cs - Amazon DynamoDB
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

03-GetItem-Test.cs

The 03-GetItem-Test.cs program performs GetItem operations on TryDaxTable.

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 using System; using System.Collections.Generic; using System.Threading.Tasks; using Amazon.DAX; using Amazon.DynamoDBv2.Model; using Amazon.Runtime; namespace ClientTest { class Program { public static async Task Main(string[] args) { string endpointUri = args[0]; Console.WriteLine($"Using DAX client - endpointUri={endpointUri}"); var clientConfig = new DaxClientConfig(endpointUri) { AwsCredentials = FallbackCredentialsFactory.GetCredentials() }; var client = new ClusterDaxClient(clientConfig); var tableName = "TryDaxTable"; var pk = 1; var sk = 10; var iterations = 5; var startTime = System.DateTime.Now; for (var i = 0; i < iterations; i++) { for (var ipk = 1; ipk <= pk; ipk++) { for (var isk = 1; isk <= sk; isk++) { var request = new GetItemRequest() { TableName = tableName, Key = new Dictionary<string, AttributeValue>() { {"pk", new AttributeValue {N = ipk.ToString()} }, {"sk", new AttributeValue {N = isk.ToString() } } } }; var response = await client.GetItemAsync(request); Console.WriteLine($"GetItem succeeded for pk: {ipk},sk: {isk}"); } } } var endTime = DateTime.Now; TimeSpan timeSpan = endTime - startTime; Console.WriteLine($"Total time: {timeSpan.TotalMilliseconds} milliseconds"); Console.WriteLine("Hit <enter> to continue..."); Console.ReadLine(); } } }