Exclusive claim with SET NX PX
An exclusive Redis claim is a temporary lease created with SET key value NX PX milliseconds. NX ensures that only one concurrent operation can create the claim, while PX automatically expires it after the specified duration. The stored value identifies the owner and must be checked before the claim is released.
Minimal example
acquired, err := rdb.SetNX(
ctx,
"order:501:claim",
"offer-8f3a",
30*time.Second,
).Result()
if err != nil {
return err
}