couchbasetransactionaldistributed-transactionscouchbase-java-api

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.!


Solution

  • 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).