Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to flush Couchbase bucket from Java code?

Tags:

java

couchbase

I need to clear a Couchbase bucket each time before unit test runs. I use the Java SDK > 2.0 version. In previous versions I found this wonderful method http://www.couchbase.com/autodocs/couchbase-java-client-1.1.1/com/couchbase/client/ClusterManager.html#flushBucket(java.lang.String) but it does not exist in new version.

Is there some way to clear data from bucket? I could delete by fetching all keys of documents and then delete them all, but I want to use more pretty way.

like image 960
Oleksandr H Avatar asked Aug 29 '15 15:08

Oleksandr H


People also ask

What is flush in Couchbase?

The Flush option flags the items for removal in a memcached bucket and immediately removes items in a Couchbase bucket.

What is couchbase SDK?

Couchbase is JSON database that excels in high volume transactions.


1 Answers

Actually in the 2.x SDK you can get a BucketManager out of a Bucket instance, which will allow you to call flush() as wonderfully as before ;)

like image 160
Simon Baslé Avatar answered Oct 16 '22 15:10

Simon Baslé