03- GetItem -Test.cs - Amazon DynamoDB

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

03- GetItem -Test.cs

Program 03-GetItem-Test.cs melakukan operasi GetItem di TryDaxTable.

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(); } } }