best practices to work with buckets in java-client

Brian Roach roach at basho.com
Sat Feb 16 02:56:01 EST 2013


You only ever need to use client.createBucket() if you want to change
the bucket properties from the defaults.

This is due to the way Riak works; a put or fetch operation that uses
a bucket that doesn't exist will create that bucket with the default
bucket properties.

To be clear, if you do:

Bucket b = client.fetchBucket("Some_bucket").execute();

That bucket did not have to exist beforehand. It will be created with
the default properties.

- Roach

On Fri, Feb 15, 2013 at 11:53 PM, Deepak Balasubramanyam
<deepak.balu at gmail.com> wrote:
>> Can I create it once (on application's start) and store somewhere (like
>> static field for example)
>
>
> Yes you can. There is no need to create the bucket every time the
> application starts. The client.fetchBucket() call will get the bucket
> successfully on subsequent runs.
>
> Thanks
> -Deepak
>
> On Sat, Feb 16, 2013 at 5:00 AM, Guido Medina <guido.medina at temetra.com>
> wrote:
>>
>> I would say it is totally safe to treat them as singleton (static
>> reference or just singleton pattern), we have been doing that for a year
>> with no issues so far.
>>
>> Hope that helps,
>>
>> Guido.
>>
>>
>> On 15/02/13 22:07, Mikhail Tyamin wrote:
>>>
>>> Hello guys,
>>>
>>> what is the best way to work with Bucket object in java-client?
>>>
>>> Can I create it once (on application's start) and store somewhere (like
>>> static field for example)
>>> or I should create it ( riakClient.createBucket("bucketName") ) once and
>>> then fetch it  ( riakClient.fetchBucket("bucketName") )
>>> every time using riakClient when I need it?
>>>
>>> P.S. I am going to use the same bucket's properties (nVal, allowSiblings
>>> and etc.) during all life of application.
>>>
>>> Thank you.
>>>
>>> Mikhail.
>>> _______________________________________________
>>> riak-users mailing list
>>> riak-users at lists.basho.com
>>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>
>>
>>
>> _______________________________________________
>> riak-users mailing list
>> riak-users at lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>




More information about the riak-users mailing list