Skip to main content
Use SDIFF to get the members of the first set that are not present in any of the other sets. Keys that do not exist count as empty sets, so a missing first key yields an empty result. The difference is computed on the fly and nothing is stored; use SDIFFSTORE to keep the result. It answers questions of the form “who is in A but not in B”, such as users who signed up but never converted. The cost grows with the size of the sets involved, so on large sets prefer storing the result and reusing it.

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.