Search:

Search all manuals
Search this manual
Manual
Membase Client Library: Java
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
1 Membase Client Library: Java — Getting Started
Chapter Sections
Chapters

1.5. Shutting down the Connection

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:

ConstantDescription
TimeUnit.NANOSECONDSNanoseconds (10 -9 s).
TimeUnit.MICROSECONDSMicroseconds (10 -6 s).
TimeUnit.MILLISECONDSMilliseconds (10 -3 s).
TimeUnit.SECONDSSeconds.

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.