Documents may be locked and unlocked on the server. While a document is locked, any attempt to modify it (or lock it again) will fail.
- Note
- Locks are not persistent across nodes (if a node fails over, the lock is not transferred to a replica).
-
The recommended way to manage access and concurrency control for documents in Couchbase is through the CAS (See lcb_CMDBASE::cas and lcb_RESPBASE::cas), which can also be considered a form of opportunistic locking.
- Locking an item
- There is no exclusive function to lock an item. Locking an item is done using lcb_get3(), by setting the lcb_CMDGET::lock option to true.
Unlock a previously locked item using lcb_CMDGET::lock.
- Stability
- Committed:
- Parameters
-
instance | the instance |
cookie | the context pointer to associate with the command |
cmd | the command containing the information about the locked key |
- Returns
- LCB_SUCCESS if successful, an error code otherwise
- See also
- lcb_get3()
- Request
Response structure for an unlock command.
- Note
- the lcb_RESPBASE::cas field does not contain the CAS of the item