The preferred method for closing a connection is to cleanly
shutdown the active connection with a timeout using the
shutdown() method with an optional
timeout period and unit specification. The following will shutdown
the active connection to all the configured servers after 60
seconds:
membase.shutdown(60, TimeUnit.SECONDS);
The unit specification relies on the TimeUnit
object enumerator, which supports the following values:
| Constant | Description |
|---|---|
TimeUnit.NANOSECONDS | Nanoseconds (10 -9 s). |
TimeUnit.MICROSECONDS | Microseconds (10 -6 s). |
TimeUnit.MILLISECONDS | Milliseconds (10 -3 s). |
TimeUnit.SECONDS | Seconds. |
The method returns a boolean value indicating
whether the shutdown request completed successfully.
You also can shutdown an active connection immediately by using
the shutdown() method to your Memcached
object instance. For example:
membase.shutdown();
In this form the shutdown() method
returns no value.