Skip to content
Snippets Groups Projects
Commit 7f20bcbb authored by kunalsomani's avatar kunalsomani Committed by Sean Busbey
Browse files

[couchbase2] Added support for ttl in Couchbase2 (#803)

[couchbase2] Added support for ttl in Couchbase2
parent 1286bdde
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment