Skip to main content
Use SADD to add one or more members to a set, creating it when the key does not exist. A set holds unique, unordered members, so adding a member that is already there changes nothing, and the reply counts only the members that were actually new. That count is what makes the command a cheap deduplicator: a reply of 1 means this caller was the first to see the value, which is enough to decide whether to process an event or ignore it as a repeat.

Syntax

Arguments

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Related topics

SADDOverview