萨德

语法
SADD key member [member ...]
从以下位置开始可用:
1.0.0
时间复杂度:
O(1) 表示每个添加的元素,因此 O(N) 在使用多个参数调用命令时添加 N 个元素。
ACL 类别:
@write, @set, @fast,

将指定成员添加到存储在key. 已是此集成员的指定成员将被忽略。 如果key不存在,则会在添加指定的 成员。

当存储在key不是一个集合。

例子

Give these commands a try in the interactive console:

SADD myset "Hello" SADD myset "World" SADD myset "World" SMEMBERS myset

RESP2/RESP3 Reply

Integer reply: the number of elements that were added to the set, not including all the elements already present in the set.

History

  • Starting with Redis version 2.4.0: Accepts multiple member arguments.
RATE THIS PAGE
Back to top ↑