redis SADD command


  Translation results:

UK [sæd] US [sæd]

n. (The upper reaches of the White Nile) large floating plants

redis SADD commandsyntax

Function:Add one or more member elements to the set key. Member elements that already exist in the set will be ignored.

Syntax: SADD key member [member ...]

Description: If key does not exist, create one containing only member elements collection of members. When key is not a collection type, an error is returned. Before Redis 2.4, SADD only accepted a single member value.

Available versions: >= 1.0.0

Time complexity: O(N), N is the number of elements being added .

Returns: The number of new elements added to the collection, excluding ignored elements.

redis SADD commandexample

# 添加单个元素
redis> SADD bbs "discuz.net"
(integer) 1
# 添加重复元素
redis> SADD bbs "discuz.net"
(integer) 0
# 添加多个元素
redis> SADD bbs "tianya.cn" "groups.google.com"
(integer) 2
redis> SMEMBERS bbs
1) "discuz.net"
2) "groups.google.com"
3) "tianya.cn"

Home

Videos

Q&A