Shivansh
Shivansh

Reputation: 3544

How can we update documents transactionally in couchbase?

I have a use case in which there are three documents and I want to update them transactionally i.e. if any of them fails then other too should not get updated in the database. I was looking for an option but didn't find one in JavaSDK. So is there any way in which I can perform this operation transactionally. I am using the CAS value for handling the concurrency. Please provide me a way to handle this operation concurrently.

Couchbase Version: 4.0 Java SDK: 2.1.6

Any help is appreciated.!

Upvotes: 1

Views: 1879

Answers (3)

Graham Pople
Graham Pople

Reputation: 516

Couchbase now supports full ACID distribution transactions in the beta release of Couchbase Server 6.5. Please see this blog post for more details and links to the documentation.

Upvotes: 0

FuzzyAmi
FuzzyAmi

Reputation: 8157

this doc (from couchbase) seems relevant: Providing transactional logic

Upvotes: 0

Simon Baslé
Simon Baslé

Reputation: 28351

Couchbase is a NoSQL database, where there is a tradeoff between ACID properties of traditional RDBMS and performance and scalability.

The only atomicity that couchbase can enforce is at the level of a single document.

There could be writings around the web on how to implement a transaction system with Couchbase, but that is clearly not something supported off-the-shelf, by design. It is a very complicated endeavour that I wouldn't recommend.

Try to model your documents differently first, so that the mutation can occur on a single document (where CAS could then be used).

Upvotes: 5

Related Questions