SADD
AttentionThis page documents an earlier version. Go to the latest (v2.1)version.
Synopsis
SADD key value [value …]This command adds one or more given values to the set that is associated with the given key.
- If the
keydoes not exist, a new set is created, and members are added with the given values. - If the
keyis associated with a value that is not a set, an error is raised. - If a specified
valuealready exists in the given set, thatvalueis ignored and not counted toward the total of newly added members.
Return Value
Depends on the configuration parameter emulate_redis_responses.
- If
emulate_redis_responsesistrue, returnsthe number of new members that were added by this command not including the duplicates. - If
emulate_redis_responsesisfalse, returns OK.
Examples
emulate_redis_responsesistrue.
1. $ SADD yuga_world "Africa"
1. 1
1. $ SADD yuga_world "America"
1. 1
1. $ SMEMBERS yuga_world
1. 1) "Africa"
2. 2) "America"
emulate_redis_responsesisfalse.
1. $ SADD yuga_world "Africa"
1. "OK"
1. $ SADD yuga_world "America"
1. "OK"
1. $ SMEMBERS yuga_world
1. 1) "Africa"
2. 2) "America"
