Couchbase SDK 3.0 enable/disable flush option from java

Viewed 254

I'm trying to enable/disable bucket flush option using below code and it doesn't work. (SDK 3.0)

public static void main(String... args) {
    Cluster cluster = Cluster.connect("host", "user", "password");
    cluster.bucket("bucketName").async();
    cluster.buckets().getBucket("bucketName").flushEnabled(true);
    cluster.buckets().flushBucket("bucketName");
}

Is there any other way to do it? (If i enable the bucket option to flush, i am able to flush the bucket using above code.)

1 Answers

You're missing a call to updateBucket which saves the modified settings:

public void setFlushable(Cluster cluster, String bucket, boolean flushable) {
  BucketSettings settings = cluster.buckets().getBucket(bucket);
  settings.flushEnabled(flushable);
  cluster.buckets().updateBucket(settings);
}
Related