Avoiding Race Conditions and Document Versioning
Our project is considering migrating from CouchDB to CouchBase. The initial benchmarks and prototype perform really well. One of the features in CouchDB we really liked was the embedded document versioning. Each document had the
_rev field. If you attempted to update an existing document and the _rev field was not a proper increment the database would fail and send the client an error. We relied on this heavily to avoid race conditions.
A typical service request is handled somewhat like this:
1. Client sends request to service.
2. Service retrieves CouchDB document
3. Service updates necessary fields to reflect client requests
4. Service updates the document on CouchDB
If the document was updated in the middle of this service operation the _rev would be incremented by the other update operation, preventing the document from being clobbered by this other service request by sending the client an error saying that the _rev field was different.
Is there a similar feature in CouchBase 2.0 that we can leverage to obtain a similar functionality?