So save(obj) will simply put the object into the memory of couchbase cluster and return. Does it put the object to memory of multiple nodes or simply only to the leader node’s memory and return?
save(obj) waits for the document to be written to memory in one place (the node hosting the active partition… the “leader” if you like). As daschl mentioned, Couchbase will still write the document to disk and replicate it, but you will not receive confirmation when the persistence and replication are complete.
So if it is put only to only leaders node memory there is a possibility of complete data loss upon leader node crash.
Correct. If the Couchbase node hosting the active partition fails before the document is written to disk or replicated to another node, the document is lost.
other overload guarantees that object is written to the disk of persist and replica nodes before return to user.
ReplicateTo lets you wait for confirmation that the document is in memory on the specified number of replicas.
PersistTo lets you wait for confirmation that the document has been written to disk on the specified number of nodes. The overloaded method lets you control whether to wait for replication, persistence, or both.
Sandhya Krishnamurthy wrote an interesting blog post on the subject: Choosing the right fit – Immediate or Eventual Persistence?