I am planing to use Couchbase as Documentation store in my web application. I am looking at Couchbase client for Java, and you need to create separate Couchbase Client for each bucket, if I treat Couchbase bucket as I would treat generic entity. This is a bit of overkill for the system (though, I can reuse executing service to minimize object creation and thread management overhead.)
So
You should treat couchbase bucket like a database. One bucket per application in most cases should be enough. But I prefer to have 2 buckets. One for common data and one for "temporary" or "fast changing" (like cache, user sessions, etc.) data. For the last purpose you can even use just memcached bucket.
And answering your 2 questions:
I don't know such way and never seen that someone even tried to do that. But remember that that client should implement singleton pattern. So if you have 2 buckets for your application, you'll only have 2 clients (that's definitely doesn't overkill something)
As I said before treat bucket like a database. You even don't need to create test
database. Couchbase has built-in separated dev
and production
views, and you can easily test your app on production data with dev
views.
About using a bucket as table/database, this post explains pretty well: http://blog.couchbase.com/10-things-developers-should-know-about-couchbase
- Start with everything in one bucket
A bucket is equivalent to a database. You store objects of different characteristics or attributes in the same bucket. So if you are moving from a RDBMS, you should store records from multiple tables in a single bucket.
Remember to create a “type” attribute that will help you differentiate the various objects stored in the bucket and create indexes on them. It is recommended to start with one bucket and grow to more buckets when necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With