Connecting to Cache Nodes Manually - Amazon ElastiCache
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Connecting to Cache Nodes Manually

If your client program does not use Auto Discovery, it can manually connect to each of the cache nodes. This is the default behavior for Memcached clients.

You can obtain a list of cache node hostnames and port numbers from the Amazon Management Console. You can also use the Amazon CLI aws elasticache describe-cache-clusters command with the --show-cache-node-info parameter.

Example

The following Java code snippet shows how to connect to all of the nodes in a four-node cache cluster:

... ArrayList<String> cacheNodes = new ArrayList<String>( Arrays.asList( "mycachecluster.fnjyzo.0001.use1.cache.amazonaws.com:11211", "mycachecluster.fnjyzo.0002.use1.cache.amazonaws.com:11211", "mycachecluster.fnjyzo.0003.use1.cache.amazonaws.com:11211", "mycachecluster.fnjyzo.0004.use1.cache.amazonaws.com:11211")); MemcachedClient cache = new MemcachedClient(AddrUtil.getAddresses(cacheNodes)); ...
Important

If you scale up or scale down your cache cluster by adding or removing nodes, you will need to update the list of nodes in the client code.