Back to Redis

ZDIFF

content/commands/zdiff.md

latest1.5 KB
Original Source

{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}

This command is similar to [ZDIFFSTORE]({{< relref "/commands/zdiffstore" >}}), but instead of storing the resulting sorted set, it is returned to the client.

Examples

{{% redis-cli %}} ZADD zset1 1 "one" ZADD zset1 2 "two" ZADD zset1 3 "three" ZADD zset2 1 "one" ZADD zset2 2 "two" ZDIFF 2 zset1 zset2 ZDIFF 2 zset1 zset2 WITHSCORES {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="zdiff-return-info" tab1="RESP2" tab2="RESP3" >}}

  • Array reply: the result of the difference including, optionally, scores when the WITHSCORES option is used.

-tab-sep-

  • Array reply: the result of the difference including, optionally, scores when the WITHSCORES option is used.

{{< /multitabs >}}