SADD key member
Add the specified member to the set value stored at the key. If a member is already a member of the set no operation is performed
Note
1. If the key does not exist a new set with the specified member as a sole member is created.
2. If the key exists but does not hold a set value an error is returned.
TIME COMPLEXITY: O(1)
RETURN VALUE: Integer reply, specifically:
1 if the new element was added
0 if the element was already a member of the set
Syntax:
SADD key member
Example 1: When key is not present or if present then held set.
redis:6379> SADD setKey 1000(integer) 1
Output
1
Example 2: When the key is present and not held set.
redis:6379> SADD mykey 1000(error) WRONGTYPE Operation against a keyholding the wrong kind of value
Output
(error) WRONGTYPE Operation against a key holding the wrong kind of value
No comments:
Post a Comment