Skip to main content
Use ZDIFFSTORE to compute the difference between sorted sets and store it in another key. The destination receives the members of the first source that appear in none of the others, keeping their scores from that source. It is overwritten if it exists and deleted when the result is empty, and the reply is the number of members stored. Materializing the result is worthwhile when the same filtered ranking is read repeatedly or paged through, since the destination is an ordinary sorted set.

Syntax

Arguments

Important points

  • numkeys must equal the number of key arguments that immediately follow it.

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.