MSETNX key1 value1 key2 value2 ... keyN valueN
Set the respective keys to the respective values.
TIME COMPLEXITY: O(1) to set every key
Note: MSETNX will not perform any operation at all even if just a single key already exists.
RETURN VALUE: Integer reply, specifically:
1 if all the keys were set
0 if no key was set (at least one key already existed)
Syntax:
MSETNX key1 value1 key2 value2 ... keyN valueN
Example 1: When the key is already present
redis:6379> MSETNX redisKey1 value4(integer) 0
Output
0
Example 2: When the key is not already present
redis:6379> MSETNX redisKey3 value4(integer) 1
Output
1
No comments:
Post a Comment