Concept Flow - SETNX for set-if-not-exists
Receive SETNX command
Check if key exists?
Yes→Return 0 (no set)
No
Set key with value
Return 1 (set successful)
The SETNX command checks if a key exists. If not, it sets the key with a value and returns 1. If the key exists, it does nothing and returns 0.