如何从Java代码刷新Couchbase存储桶?
每次运行单元测试之前,我都需要清除一个Couchbase存储桶.我使用Java SDK> 2.0版本.在以前的版本中,我发现了一种很棒的方法
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.
实际上,在2.x SDK中,您可以从 Bucket
实例中获取 BucketManager
将使您像以前一样美妙地调用 flush()
;)
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 ;)