03- GetItem -Test.cs - Amazon DynamoDB

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

03- GetItem -Test.cs

Le programme 03-GetItem-Test.cs exécute des opérations GetItem sur 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(); } } }