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

Data Structures and Algorithms in Java

Data Structures and Algorithms in Java

Michael T. Goodrich、Roberto Tamassia / Wiley / 2010-01-26 / USD 177.41

* This newest edition examines fundamental data structures by following a consistent object-oriented framework that builds intuition and analysis skills of data structures and algorithms * Presents ne......一起来看看 《Data Structures and Algorithms in Java》 这本书的介绍吧!

URL 编码/解码

URL 编码/解码

URL 编码/解码

html转js在线工具

html转js在线工具

html转js在线工具

RGB HSV 转换

RGB HSV 转换

RGB HSV 互转工具