SADD
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
key
does not exist, a new set is created, and members are added with the given values. - If the
key
is associated with a value that is not a set, an error is raised. - If a specified
value
already exists in the given set, thatvalue
is ignored and not counted toward the total of newly added members.
Return value
Depends on the configuration parameter emulate_redis_responses
.
- If
emulate_redis_responses
istrue
, returnsthe number of new members that were added by this command not including the duplicates. - If
emulate_redis_responses
isfalse
, returns OK.
Examples
emulate_redis_responses
istrue
.
$ SADD yuga_world "Africa"
1
$ SADD yuga_world "America"
1
$ SMEMBERS yuga_world
1) "Africa"
2) "America"
emulate_redis_responses
isfalse
.
$ SADD yuga_world "Africa"
"OK"
$ SADD yuga_world "America"
"OK"
$ SMEMBERS yuga_world
1) "Africa"
2) "America"
See also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .