- Redis Basics
- Redis - Home
- Redis - Overview
- Redis - Environment
- Redis - Configuration
- Redis - Data types
- Redis Commands
- Redis - Commands
- Redis - Keys
- Redis - Strings
- Redis - Hashes
- Redis - Lists
- Redis - Sets
- Redis - Sorted Sets
- Redis - HyperLogLog
- Redis - Publish Subscribe
- Redis - Transactions
- Redis - Scripting
- Redis - Connections
- Redis - Server
- Redis Advanced
- Redis - Backup
- Redis - Security
- Redis - Benchmarks
- Redis - Client Connection
- Redis - Pipelining
- Redis - Partitioning
- Redis - Java
- Redis - Php
- Redis Useful Resources
- Redis - Quick Guide
- Redis - Useful Resources
- Redis - Discussion
Redis - String Setnx Command
Redis SETNX command is used to set some string value in Redis key, if the key does not exist in Redis. Fullform of SETNX is SET if Not eXists.
Return Value
Integer reply 1 or 0
- 1, if the key is set.
- 0, if the key is not set.
Syntax
Following is the basic syntax of Redis SETNX command.
redis 127.0.0.1:6379> SETNX KEY_NAME VALUE
Example
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"
redis_strings.htm
Advertisements
To Continue Learning Please Login
Login with Google