Search:

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

4.1. Synchronous get Methods

The synchronous get() methods allow for direct access to a given key/value pair.

API Callclient.get(key)
Asynchronousno
Description Get one or more key values
ReturnsObject ( Binary object )
Arguments 
String key Document ID used to identify the value

The get() method obtains an object stored in Membase using the default transcoder for serialization of the object.

For example:

Object myObject = membase.get("someKey");

Transcoding of the object assumes the default transcoder was used when the value was stored. The returned object can be of any type.

If the request key does not exist in the database then the returned value is null.

API Callclient.get(key, transcoder)
Asynchronousno
Description Get one or more key values
ReturnsT ( Transcoded object )
Arguments 
String key Document ID used to identify the value
Transcoder<T> transcoder Transcoder class to be used to serialize value

The second form of the get() retrieves a value from Membase using a custom transcoder.

For example to obtain an integer value using the IntegerTranscoder:

Transcoder<Integer> tc = new IntegerTranscoder();
Integer ic = membase.get("someKey", tc);