Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library: Java 1.1
Community Wiki and Resources
Download Client Library
JavaDoc
Couchbase Developer Guide 2.0
Couchbase Server Manual 2.0
Java Client Library
SDK Forum
Wiki: Java Client Library
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
8 Update Operations
Chapter Sections
Chapters

8.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:

OperationFuture<Boolean> replaceOp =
    client.replace("samplekey","updatedvalue",0);

The return value is a OperationFuture 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.