English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Redis SADD command adds one or more member elements to the set, and elements that already exist in the set will be ignored.
If the set key does not exist, a set is created that contains only the elements added.
If the key of the set is not a set type, an error is returned.
Note:In Redis2.4 Before the version, SADD only accepted a single member value.
Basic Syntax of Redis SADD Command:
redis 127.0.0.1:6379> SADD KEY_NAME VALUE1..VALUEN
>= 1.0.0
The number of new elements added to the set, excluding ignored elements.
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"