The constructor for
three different formats:
For specifying multiple addresses as individual arguments to the constructor.
For specifying multiple addresses as a list of individual addresses as a single argument to the constructor.
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
AddrUtil utility class to parse
strings into hostname and port combinations. The
AddrUtil.getAddresses() method parses the
string and returns a
InetSocketAddress objects . The sample below is
the equivalent code to the
method used above:
MemcachedClient c = new MemcachedClient( AddrUtil.getAddresses("servera:11211")););
AddrUtil utility class is also the easiest
method for specifying multiple hostname/port combinations, by
hostname:port combination with
MemcachedClient c = new MemcachedClient( AddrUtil.getAddresses("servera:11211 serverb:11211")););
MemcachedClient constructors return the
IOException exception if a valid connection is
unable to be made.