Menggunakan Klien ElastiCache Cluster untuk. NET - Amazon ElastiCache

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

Menggunakan Klien ElastiCache Cluster untuk. NET

catatan

Itu ElastiCache . NETklien cluster tidak digunakan lagi per Mei 2022.

. NETklien untuk ElastiCache adalah open source di https://github.com/awslabs/elasticache-cluster-config-net.

. NETaplikasi biasanya mendapatkan konfigurasinya dari file konfigurasi mereka. Berikut ini adalah contoh file config aplikasi.

<?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>

Program C# di bawah ini menunjukkan cara menggunakan Klien ElastiCache Cluster untuk terhubung ke titik akhir konfigurasi cluster dan menambahkan item data ke cache. Dengan Penemuan Otomatis, program ini akan terhubung ke semua simpul di klaster tanpa intervensi lebih lanjut.

// ***************** // 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