- 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 Msetnx Command
Redis MSETNX command is used to set multiple values to multiple keys, only if none of them already exist. If any one from the current operation exists in Redis, then MSETNX does not perform any operation.
Return Value
Integer reply 1 or 0
- 1, if all the keys are set in Redis.
- 0, if no keys are set in Redis.
Syntax
Following is the basic syntax of Redis MSETNX command.
redis 127.0.0.1:6379> MSETNX key1 value1 key2 value2 .. keyN valueN
Example
redis 127.0.0.1:6379> MSETNX key1 "Hello" key2 "world" (integer) 1 redis 127.0.0.1:6379> MSETNX key2 "worlds" key3 "third key" (integer) 0 redis 127.0.0.1:6379> MGET key1 key2 key3 1) "Hello" 2) "world" 3) (nil)
redis_strings.htm
Advertisements