の ElastiCache クラスタークライアントの使用。NET - Amazon ElastiCache

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

の ElastiCache クラスタークライアントの使用。NET

注記

ElastiCache クラスターNETクライアントは、2022 年 5 月をもって廃止されました。

。NET の クライアント ElastiCache は のオープンソースですhttps://github.com/awslabs/elasticache-cluster-config-net

。NETアプリケーションは通常、設定ファイルから設定を取得します。サンプルアプリケーションの config ファイルを以下に示します。

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

以下の C# プログラムでは、 ElastiCache クラスタークライアントを使用してクラスター設定エンドポイントに接続し、データ項目をキャッシュに追加する方法を示します。さらに操作を行わなくても、プログラムは自動検出を使用してクラスター内のすべてのノードに接続します。

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