Skip to main content

SETNX

Note

Official reference: SETNX.

Write a string only if the key does not exist.

Syntax​

SETNX key value

The corresponding EX, PX or NX option of SET is also available.

Results​

ReturnRowsContent
Update count--1 if key was set; 0 otherwise

Example​

SETNX demo:new-message hello