It is now possible to create and delete buckets from the client directly, without the need to switch to the UI or use the REST API. The functionality is provided through the new ClusterManager class. Here is a short example on how to use it:
// Connect with cluster admin and password ClusterManager manager = new ClusterManager(uris, "Administrator", "password"); // Create a new bucket with authentication manager.createSaslBucket(BucketType.COUCHBASE, "saslbucket", 100, 0, "password"); // Delete the bucket again manager.deleteBucket("saslbucket");
See the documentation for more details and usage examples.
This release adds the possibility of providing a durability setting that allows to make sure data is replicated but not persisted. This may speed up operations while allowing to maintain a reasonable safety net at the same time (wait until the operation has been replicated to the given number of nodes). Also, every command takes either ReplicateTo, PersistTo or both.
Here is an usage example of an add operation which makes sure to replicate to at least one node:
// With ReplicateTo only client.add("mykey", 0, "value", ReplicateTo.ONE); // Identical to this client.add("mykey", 0, "value", PersistTo.ZERO, ReplicateTo.ONE);
A new ComplexKey class has ben added as a utility to define view query options. This makes it possible to convert Java types into their corresponding JSON representations as easy as possible. Also, this avoids the need to encode the values by hand to encode them properly. Passing in a string does still work, but the ComplexKey approach is recommended when working with arrays or other more complex JSON structures.
Here is a short example on how to use it properly:
// JSON Result: 100 ComplexKey.of(100); // JSON Result: "Hello" ComplexKey.of("Hello"); // JSON Result: ["Hello", "World"] ComplexKey.of("Hello", "World"); // JSON Result: [1349360771542,1] ComplexKey.of(new Date().getTime(), 1);
When querying a view it looks like this:
long now = new Date().getTime(); long tomorrow = now + 86400; Query query = new Query(); query.setRange(ComplexKey.of(now), ComplexKey.of(tomorrow)); // Converts to: ?startkey=1349362647742&endkey=1349362734142
When a HTTP operation is cancelled, it is now ensured that the corresponding HTTP request is also cancelled. This prevents a possible issue where the calling thread is blocked longer than needed.
The CouchbaseClient now does not try to establish view connections on memcache buckets. This makes it possible to connect to memcache buckets on the 1.1 series again.
Behind the scenes, the HTTP query parameters for the views are now properly encoded. This means that passing characters like spaces don't break view queries anymore. This fix also ensures that query parameters generated through ComplexKey.of work properly.
The update_seq param has been removed from the possible Query options because it has also been removed from Couchbase Server 2.0 as well.