redis使用之setnx
Examples
shell:
redis> SETNX mykey "Hello"
(integer) 1redis> SETNX mykey "World"
(integer) 0redis> GET mykey
"Hello"
shell:
(integer) 1redis> SETNX mykey "World"
(integer) 0redis> GET mykey
"Hello"