Adding Auto Discovery To Your Client Library - 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).

Adding Auto Discovery To Your Client Library

The configuration information for Auto Discovery is stored redundantly in each cache cluster node. Client applications can query any cache node and obtain the configuration information for all of the nodes in the cluster.

The way in which an application does this depends upon the cache engine version:

  • If the cache engine version is 1.4.14 or higher, use the config command.

  • If the cache engine version is lower than 1.4.14, use the get AmazonElastiCache:cluster command.

The outputs from these two commands are identical, and are described in the Output Format section below.

Cache Engine Version 1.4.14 or Higher

For cache engine version 1.4.14 or higher, use the config command. This command has been added to the Memcached ASCII and binary protocols by ElastiCache, and is implemented in the ElastiCache Cluster Client. If you want to use Auto Discovery with another client library, then that library will need to be extended to support the config command.


The following documentation pertains to the ASCII protocol; however, the config command supports both ASCII and binary. If you want to add Auto Discovery support using the binary protocol, refer to the source code for the ElastiCache Cluster Client.


config [sub-command] [key]


Name Description Required

The sub-command used to interact with a cache node. For Auto Discovery, this sub-command is get.


The key under which the cluster configuration is stored. For Auto Discovery, this key is named cluster.


To get the cluster configuration information, use the following command:

config get cluster

Cache Engine Version Lower Than 1.4.14

To get the cluster configuration information, use the following command:

get AmazonElastiCache:cluster

Do not tamper with the "AmazonElastiCache:cluster" key, since this is where the cluster configuration information resides. If you do overwrite this key, then the client may be incorrectly configured for a brief period of time (no more than 15 seconds) before ElastiCache automatically and correctly updates the configuration information.

Output Format

Whether you use config get cluster or get AmazonElastiCache:cluster, the reply consists of two lines:

  • The version number of the configuration information. Each time a node is added or removed from the cache cluster, the version number increases by one.

  • A list of cache nodes. Each node in the list is represented by a hostname|ip-address|port group, and each node is delimited by a space.

A carriage return and a linefeed character (CR + LF) appears at the end of each line. The data line contains a linefeed character (LF) at the end, to which the CR + LF is added. The config version line is terminated by LF without the CR.

A cache cluster containing three nodes would be represented as follows:

configversion\n hostname|ip-address|port hostname|ip-address|port hostname|ip-address|port\n\r\n

Each node is shown with both the CNAME and the private IP address. The CNAME will always be present; if the private IP address is not available, it will not be shown; however, the pipe characters "|" will still be printed.


Here is an example of the payload returned when you query the configuration information:

CONFIG cluster 0 136\r\n 12\n||11211||11211\n\r\n END\r\n
  • The second line indicates that the configuration information has been modified twelve times so far.

  • In the third line, the list of nodes is in alphabetical order by hostname. This ordering might be in a different sequence from what you are currently using in your client application.