Method: Redis::Commands::SortedSets#zdiff

Defined in:
lib/redis/commands/sorted_sets.rb

#zdiff(*keys, with_scores: false) ⇒ Array<String>, Array<[String, Float]>

Return the difference between the first and all successive input sorted sets

Examples:

redis.zadd("zsetA", [[1.0, "v1"], [2.0, "v2"]])
redis.zadd("zsetB", [[3.0, "v2"], [2.0, "v3"]])
redis.zdiff("zsetA", "zsetB")
  => ["v1"]

With scores

redis.zadd("zsetA", [[1.0, "v1"], [2.0, "v2"]])
redis.zadd("zsetB", [[3.0, "v2"], [2.0, "v3"]])
redis.zdiff("zsetA", "zsetB", :with_scores => true)
  => [["v1", 1.0]]

Parameters:

  • keys (String, Array<String>)

    one or more keys to compute the difference

  • options (Hash)
    • ‘:with_scores => true`: include scores in output

Returns:

  • (Array<String>, Array<[String, Float]>)
    • when ‘:with_scores` is not specified, an array of members

    • when ‘:with_scores` is specified, an array with `[member, score]` pairs



721
722
723
# File 'lib/redis/commands/sorted_sets.rb', line 721

def zdiff(*keys, with_scores: false)
  _zsets_operation(:zdiff, *keys, with_scores: with_scores)
end