The Java Client Libraries support the core Couchbase API methods as direct calls to the Couchbase server through the API call. These direct methods can be used to provide instant storage, retrieval and updating of Couchbase key/value pairs.
For example, the get() is a synchronous
operation:
Object myObject = client.get("someKey");
In the example code above, the client get()
call will wait until a response has been received from the
appropriately configured Couchbase servers before returning the
required value or an exception.
A list of the synchronous methods are shown in Table 4.2, “Java Client Library Synchronous Method Summary”.
Table 4.2. Java Client Library Synchronous Method Summary
| Method | Title |
|---|---|
client.append(casunique, key, value) | Append a value to an existing key |
client.append(casunique, key, value, transcoder) | Append a value to an existing key |
client.cas(key, casunique, value) | Compare and set |
client.cas(key, casunique, expiry, value, transcoder) | Compare and set with a custom transcoder and expiry |
client.cas(key, casunique, value, transcoder) | Compare and set with a custom transcoder |
client.decr(key, offset) | Decrement the value of an existing numeric key |
client.decr(key, offset, default) | Decrement the value of a key, setting the initial value if the key didn't already exist |
client.decr(key, offset, default, expiry) | Decrement the value of a key, setting the initial value if the key didn't already exist, with an expiry |
client.getAndTouch(key, expiry) | Get a value and update the expiration time for a given key |
client.getAndTouch(key, expiry, transcoder) | Get a value and update the expiration time for a given key using a custom transcoder |
client.get(key) | Get a single key |
client.getAndLock(key [, getl-expiry ], transcoder) | Get and lock |
client.getBulk(keycollection) | Get multiple keys |
client.getBulk(keyn) | Get multiple keys |
client.getBulk(transcoder, keyn) | Get multiple keys using a custom transcoder |
client.getBulk(keycollection, transcoder) | Get multiple keys using a custom transcoder |
client.get(key, transcoder) | Get a single key using a custom transcoder |
client.gets(key) | Get single key value with CAS value |
client.gets(key, transcoder) | Get single key value with CAS value using custom transcoder |
client.getStats() | Get the statistics from all connections |
client.getStats(statname) | Get the statistics from all connections |
client.getView(ddocname, viewname) | Create a view object |
client.incr(key, offset) | Increment the value of an existing numeric key |
client.incr(key, offset, default) | Increment the value of an existing numeric key |
client.incr(key, offset, default, expiry) | Increment the value of an existing numeric key |
client.new CouchbaseClient([ url ] [, urls ] [, username ] [, password ]) | Create connection to Couchbase Server |
client.query(view, query) | Query a view |
Query.new() | Create a query object |
client.unlock(key, casunique) | Unlock |