Alternate get and lock api

Hello,

Existing getAndLock API write locks the document. What I need is a getAndLock that throws something like DocumentLockedException on a second getAndLock call until unlock is called or expiry.

Is there a way to do this? Thanks for your reply.

With much gratitude,
Neome Web

Hi @Neome_Web,

Which SDK are you using? Go, PHP, Java, etc?

Java SDK. But I figured that instead of using getAndLock, I can use the “insert” document with TTL to do the master selection between distributed processes.

I was trying getAndLock to do the same thing.

Hi, I’m searching for the good explanaition of Pessimistic locking in Couchbase and what to use to implement that.
As far I saw getAndLock method but can’t find what API is it located.
And more if I can connect it with AttemptContext somehow.