Redis Sadd 命令

更新时间: 2019-07-07 15:54

Redis Sadd 命令将一个或多个成员元素加入到集合中,已经存在于集合的成员元素将被忽略。

假如集合 key 不存在,则创建一个只包含添加的元素作成员的集合。

当集合 key 不是集合类型时,返回一个错误。

注意:在Redis2.4版本以前, SADD 只接受单个成员值。

语法

redis 127.0.0.1:6379> SADD KEY_NAME VALUE1..VALUEN

返回值

被添加到集合中的新元素的数量,不包括被忽略的元素。

实例

redis 127.0.0.1:6379> SADD myset "hello"
(integer) 1
redis 127.0.0.1:6379> SADD myset "foo"
(integer) 1
redis 127.0.0.1:6379> SADD myset "hello"
(integer) 0
redis 127.0.0.1:6379> SMEMBERS myset
1) "hello"
2) "foo"

查看更多 Redis 集合(Set)命令

Software Engineering for Internet Applications

Software Engineering for Internet Applications

Eve Andersson、Philip Greenspun、Andrew Grumet / The MIT Press / 2006-03-06 / USD 35.00

After completing this self-contained course on server-based Internet applications software, students who start with only the knowledge of how to write and debug a computer program will have learned ho......一起来看看 《Software Engineering for Internet Applications》 这本书的介绍吧!

JSON 在线解析

JSON 在线解析

在线 JSON 格式化工具

Base64 编码/解码

Base64 编码/解码

Base64 编码/解码

html转js在线工具

html转js在线工具

html转js在线工具