Need to lock a document using get and lock so that other threads dont make the same document again till the cleanup has been performed by first thread

My goal is to make sure when one thread has created a document other threads are not able to create the same document again till the first thread has finished cleanup. I m using get and lock but its not working. The other threads are still creating the same documents before thread 1 has finished cleanup. Im using memcached buckets for storing docs.

GETL (get and lock) only works on Couchbase buckets.

@drigby So is there any way of a having a locking mechanism with memcached buckets?

There’s no pessimistic locking in the memcached protocol (which memcache buckets implement). You can use optimistic locking with CAS instead, but that will require a different design in your application.

@drigby Thanks. :slight_smile: