Java 向けの ElastiCache クラスタークライアントの使用 - Amazon ElastiCache

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

Java 向けの ElastiCache クラスタークライアントの使用

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

package com.amazon.elasticache; import java.io.IOException; import java.net.InetSocketAddress; // Import the &AWS;-provided library with Auto Discovery support import net.spy.memcached.MemcachedClient; public class AutoDiscoveryDemo { public static void main(String[] args) throws IOException { String configEndpoint = "mycluster.fnjyzo.cfg.use1.cache.amazonaws.com"; Integer clusterPort = 11211; MemcachedClient client = new MemcachedClient( new InetSocketAddress(configEndpoint, clusterPort)); // The client will connect to the other cache nodes automatically. // Store a data item for an hour. // The client will decide which cache host will store this item. client.set("theKey", 3600, "This is the data value"); } }