Alternative Locking and unlocking
I've read the document and found
alternative locking (other than using CAS)
It was using "ADD" API for the same key in order to act like "locking"
I was wondering if you have any suggestion for the "unlocking"
I am apparently using "libcouchbase" of c++ and "spymemcached" of JAVA.
for libcouchbase, I am calling libcouchbase_remove to delete the selected key.
since the document lacks a lot of information, I was wondering what does the remove aPI return for the errors.
I expect "no key", "network interruption" etc.
I would like to know how we should take care of this remove API in order to prevent any collisions?
Our logic for the project:
1. Lock ( Add)
2. Processes
3. Unlock ( Delete)
and three process are watching the same lock.
What I am really wondering about is returning Errorcode for each APIs. Since it is really important to know in order to handle the process
1. Lock (Add)
Will return EXISTS(0x02) if the lock is taken and SUCCESS(0x00) if the process has obtained the lock.
2. Processes
3. Unlock (Delete)
Will return SUCCESS(0x00) if the lock was unlocked and NOT_FOUND(0x01) if someone else removed the lock which would be an error in your client code.