MSETNX

Stores all supplied string pairs only if none of their keys exists.

Strings · Example verified

Syntax covered here

MSETNX key value [key value ...]

When one requested key already exists, the case confirms that its value stays unchanged and the other missing key is not created.

Tested example & replies

Requests below run in order against an empty database. Each connection authenticates with the fixture password first. Quoted values are strings; null is a nil reply; arrays preserve RESP order.

# connection: default
> MSETNX one 1 two 2
1
# connection: default
> MSETNX two changed three 3
0
# connection: default
> MGET one two three
["1","2",null]