You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alex Moore edited this page Jun 10, 2015
·
6 revisions
Note: This document is for the 1.x Java Client series.
Creating or modifying a bucket in Riak
importcom.basho.riak.client.IRiakClient;
importcom.basho.riak.client.RiakException;
importcom.basho.riak.client.RiakFactory;
importcom.basho.riak.client.bucket.Bucket;
publicclassApp
{
publicstaticvoidmain(String[] args) throwsRiakException
{
riakClient = RiakFactory.httpClient();
// If the bucket does not exist in Riak, it will be created with the default properties// when you use the fetchBucket() method.BucketmyBucket = riakClient.fetchBucket("TestBucket").execute();
// By using the createBucket() method you can specify properties' values. If the bucket// already exists in Riak the bucket properties will be updated.BucketmyOtherBucket = riakClient.createBucket("TestBucket").nVal(2).r(1).execute();
// If you have an existing Bucket object, you can modify the values and update RiakBucketexistingBucket = riakClient.fetchBucket("TestBucket").execute();
existingBucket = riakClient.updateBucket(existingBucket).nVal(3).r(2).execute();
riakClient.shutdown();
}
}