Utilizzo del ElastiCache Cluster Client per. NET - Amazon ElastiCache

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Utilizzo del ElastiCache Cluster Client per. NET

Nota

La ElastiCache . NETIl client del cluster è obsoleto a maggio 2022.

. NETclient for ElastiCache è open source presso https://github.com/awslabs/elasticache-cluster-config-net.

. NETle applicazioni in genere ottengono le proprie configurazioni dal proprio file di configurazione. Di seguito viene riportato un file config dell'applicazione di esempio.

<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="clusterclient" type="Amazon.ElastiCacheCluster.ClusterConfigSettings, Amazon.ElastiCacheCluster" /> </configSections> <clusterclient> <!-- the hostname and port values are from step 1 above --> <endpoint hostname="mycluster.fnjyzo.cfg.use1.cache.amazonaws.com" port="11211" /> </clusterclient> </configuration>

Il programma C# riportato di seguito mostra come utilizzare il ElastiCache Cluster Client per connettersi a un endpoint di configurazione del cluster e aggiungere un elemento di dati alla cache. Utilizzando Individuazione automatica, il programma si connette a tutti i nodi in un cluster senza ulteriori interventi.

// ***************** // Sample C# code to show how to integrate with the Amazon ElastiCcache Auto Discovery feature. using System; using Amazon.ElastiCacheCluster; using Enyim.Caching; using Enyim.Caching.Memcached; public class DotNetAutoDiscoveryDemo { public static void Main(String[] args) { // instantiate a new client. ElastiCacheClusterConfig config = new ElastiCacheClusterConfig(); MemcachedClient memClient = new MemcachedClient(config); // Store the data for 3600 seconds (1hour) in the cluster. // The client will decide which cache host will store this item. memClient.Store(StoreMode.Set, 3600, "This is the data value."); } // end Main } // end class DotNetAutoDiscoverDemo