Redis SETNX Command Explained

The Redis SETNX command sets a key to a given value, but only if the key doesn’t already exist. If the key already holds a value, no operation is performed.

Note: The SET command can do the same thing, and it’s possible that the SETNX command may be deprecated at some point. Therefore, it’s probably a good idea to use SET instead of SETNX if possible.

Continue reading