diff --git a/couchbase2/README.md b/couchbase2/README.md index d2b6aeea277234408508c79b8edf81dee54c949e..7986811fbc12f139822f39835d12d672ab2ab6eb 100644 --- a/couchbase2/README.md +++ b/couchbase2/README.md @@ -141,4 +141,5 @@ You can set the following properties (with the default settings applied): - couchbase.boost=3: If > 0 trades CPU for higher throughput. N is the number of event loops, ideally set to the number of physical cores. Setting higher than that will likely degrade performance. - couchbase.networkMetricsInterval=0: The interval in seconds when latency metrics will be logged. - - couchbase.runtimeMetricsInterval=0: The interval in seconds when runtime metrics will be logged. \ No newline at end of file + - couchbase.runtimeMetricsInterval=0: The interval in seconds when runtime metrics will be logged. + - couchbase.documentExpiry=0: Document Expiry is the amount of time(second) until a document expires in Couchbase. \ No newline at end of file diff --git a/couchbase2/src/main/java/com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java b/couchbase2/src/main/java/com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java index 73e44a046ff047b113092990c6a6ba7b6f062dee..7acd9bbbca12b6837445fb424e39492d50da404e 100644 --- a/couchbase2/src/main/java/com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java +++ b/couchbase2/src/main/java/com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java @@ -93,6 +93,8 @@ import java.util.concurrent.locks.LockSupport; * set to the number of physical cores. Setting higher than that will likely degrade performance.</li> * <li><b>couchbase.networkMetricsInterval=0</b> The interval in seconds when latency metrics will be logged.</li> * <li><b>couchbase.runtimeMetricsInterval=0</b> The interval in seconds when runtime metrics will be logged.</li> + * <li><b>couchbase.documentExpiry=0</b> Document Expiry is the amount of time until a document expires in + * Couchbase.</li> * </ul> */ public class Couchbase2Client extends DB { @@ -127,7 +129,8 @@ public class Couchbase2Client extends DB { private int networkMetricsInterval; private int runtimeMetricsInterval; private String scanAllQuery; - + private int documentExpiry; + @Override public void init() throws DBException { Properties props = getProperties(); @@ -149,6 +152,7 @@ public class Couchbase2Client extends DB { boost = Integer.parseInt(props.getProperty("couchbase.boost", "3")); networkMetricsInterval = Integer.parseInt(props.getProperty("couchbase.networkMetricsInterval", "0")); runtimeMetricsInterval = Integer.parseInt(props.getProperty("couchbase.runtimeMetricsInterval", "0")); + documentExpiry = Integer.parseInt(props.getProperty("couchbase.documentExpiry", "0")); scanAllQuery = "SELECT RAW meta().id FROM `" + bucketName + "` WHERE meta().id >= '$1' ORDER BY meta().id LIMIT $2"; @@ -342,7 +346,7 @@ public class Couchbase2Client extends DB { */ private Status updateKv(final String docId, final HashMap<String, ByteIterator> values) { waitForMutationResponse(bucket.async().replace( - RawJsonDocument.create(docId, encode(values)), + RawJsonDocument.create(docId, documentExpiry, encode(values)), persistTo, replicateTo )); @@ -412,7 +416,7 @@ public class Couchbase2Client extends DB { for(int i = 0; i < tries; i++) { try { waitForMutationResponse(bucket.async().insert( - RawJsonDocument.create(docId, encode(values)), + RawJsonDocument.create(docId, documentExpiry, encode(values)), persistTo, replicateTo )); @@ -491,7 +495,7 @@ public class Couchbase2Client extends DB { */ private Status upsertKv(final String docId, final HashMap<String, ByteIterator> values) { waitForMutationResponse(bucket.async().upsert( - RawJsonDocument.create(docId, encode(values)), + RawJsonDocument.create(docId, documentExpiry, encode(values)), persistTo, replicateTo ));