Skip to main content
Use SDIFFSTORE to compute the difference between sets and store it in another key. The destination holds the members of the first source set that are absent from all the others. It is overwritten if it already exists, and deleted when the result is empty. The reply is the number of members stored. Storing rather than returning the result is what you want when the difference is large or is used more than once, since the destination is an ordinary set that can be paged through or fed into further set operations.

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.