The constructor for MemcachedClient supports
three different formats:
MemcachedClient(InetSocketAddress...
address)
For specifying multiple addresses as individual arguments to the constructor.
MemcachedClient(List<InetSocketAddress>)
For specifying multiple addresses as a list of individual addresses as a single argument to the constructor.
MemcachedClient(ConnectionFactory factory,
List<InetSocketAddress>)
For specifying the connection type to be used to communicate to multiple addresses as a list of individual addresses as a single argument to the constructor.
To make a standard connection to your Membase node using a
standard hostname and port combination you can use the
InetSocketAddress class when creating the
MemcachedClient object. This allows you to
explicitly specify the hostname and port numbers. For example, to
connect to the host servera on port 11211:
MemcachedClient c = new MemcachedClient( new InetSocketAddress("servera", 11211));
You can also use a hostname:port string by
using the AddrUtil utility class to parse
strings into hostname and port combinations. The
AddrUtil.getAddresses() method parses the
string and returns a List of
InetSocketAddress objects . The sample below is
the equivalent code to the InetSocketAddress
method used above:
MemcachedClient c = new MemcachedClient( AddrUtil.getAddresses("servera:11211")););
The AddrUtil utility class is also the easiest
method for specifying multiple hostname/port combinations, by
separating each hostname:port combination with
a space:
MemcachedClient c = new MemcachedClient( AddrUtil.getAddresses("servera:11211 serverb:11211")););
The MemcachedClient constructors return the
IOException exception if a valid connection is
unable to be made.