Redis String: SETNX key value
SETNX key value
Redis SETNX command is used to set some string value in redis key, if the key does not exist in redis. When key already holds a value, no operation is performed. SETNX is short for "SET if Not eXists".
Syntax:
SETNX KEY_NAME VALUE
Available since
1.0.0.
Return Value
Integer replies 1 or 0
- 1, if the key is set.
- 0, if the key is not set.
Return Value Type
Integer
Example: Redis SETNX
redis 127.0.0.1:6379> SETNX mykey redis (integer) 1 redis 127.0.0.1:6379> SETNX mykey mongodb (integer) 0 redis 127.0.0.1:6379> GET mykey "redis"
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework