Search:

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

5.7. Replace Methods

The replace() methods update an existing key/value pair in the database. If the specified key does not exist, then the operation will fail.

API Callclient.replace(key, expiry, value)
Asynchronousyes
Description Update an existing key with a new value
ReturnsFuture<Boolean> ( Asynchronous request value, as Boolean )
Arguments 
String key Document ID used to identify the value
int expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
Object value Value to be stored

The first form of the replace() method updates an existing value setting while supporting the explicit setting of the expiry time on the item. For example to update the samplekey:

Future<Boolean> success =
    membase.replace("samplekey","updatedvalue",0);

The return value is a Future value with a Boolean base.

API Callclient.replace(key, expiry, value, transcoder)
Asynchronousyes
Description Update an existing key with a new value
ReturnsFuture<Boolean> ( Asynchronous request value, as Boolean )
Arguments 
String key Document ID used to identify the value
int expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).
Object value Value to be stored
Transcoder<T> transcoder Transcoder class to be used to serialize value

The second form of the replace() method is identical o the first, but also supports using a custom Transcoder in place of the default transcoder.