I want to implement locking in my application with below approach:
To get lock: Agent will call my custom API which would call couchbase server’s getAndLock API to get a lock. If it gets lock successfully, it would return CAS value otherwise would return -1. Returned CAS value would be passed to agent.
To release lock:Updated document with CAS value would be synced through Sync Gateway which would release lock if CAS value matches with that in server.
My question is where in document should I set CAS value?
Will it work through sync gateway(save doc and release lock) or should I call couchbase server API to save and release lock?