Reuse of Buckets (Java Client)

Guido Medina guido.medina at temetra.com
Wed Jul 31 04:33:53 EDT 2013


Yes, it is thread safe, you can treat them as singleton instances per 
bucket, the following order is the kind of the general usage pattern:

  * Fetch bucket.
  * Optional: If exists verify it has your application values (N value, etc)
  * If doesn't exist create it with your settings.
  * Cache it as a singleton instance (You could create a /"final
    Map<String, Bucket> buckets=new HashMap<>()"/) and re-use it in your
    application; assuming your initialization is not lazy, or if it is
    use proper thread safety initialization.

Hope that helps,

Guido.

On 31/07/13 08:45, Nico Huysamen wrote:
> Is the Bucket class reusable and thread-safe? I.e. can I create my 
> Bucket objects during instantiation of client class, and then reuse 
> the same bucket for all operations for the application lifetime? Or 
> should buckets be re-created for each request?
>
> Thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20130731/86bde2c6/attachment.html>


More information about the riak-users mailing list