How to resolve latency issue

Our requirement is to provide unique coupon to the user. We are generating unique coupons by our algorithm and storing in Couchbase DB.
We created one bucket where we are storing all the documents contain coupon codes. One column in the document is “IN USE”. While supplying the coupons to website, we are also updating this column real time, we are seeing latency of few minutes.
My question - can we lock that coupon code, until the IN USE flag is updated fully? Or do you have any other better solution to get rid of this latency of real time update.

For updates like this, you need to use compare and swap (CAS) operations. See the tutorials section and the developer guide, this will help you to make sure to not update your data if it has changed and you are not in the possession of the CAS value.

we have read locks, but I strongly vote against using them in this cases, they are sort of a last resort and also only provide write locking (also through CAS semantics) and no read locking.