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)命令

Letting Go of the Words

Letting Go of the Words

Janice (Ginny) Redish / Morgan Kaufmann / 2007-06-11 / USD 49.95

"Redish has done her homework and created a thorough overview of the issues in writing for the Web. Ironically, I must recommend that you read her every word so that you can find out why your customer......一起来看看 《Letting Go of the Words》 这本书的介绍吧!

Markdown 在线编辑器

Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换

RGB HSV 转换

RGB HSV 互转工具

RGB CMYK 转换工具

RGB CMYK 转换工具

RGB CMYK 互转工具