Method: Redis::Commands::SortedSets#zinterstore

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

#zinterstore(*args) ⇒ Integer

Intersect multiple sorted sets and store the resulting sorted set in a new key.

Examples:

Compute the intersection of ‘2*zsetA` with `1*zsetB`, summing their scores

redis.zinterstore("zsetC", ["zsetA", "zsetB"], :weights => [2.0, 1.0], :aggregate => "sum")
  # => 4

Parameters:

  • destination (String)

    destination key

  • keys (Array<String>)

    source keys

  • options (Hash)
    • ‘:weights => [Array<Float>]`: weights to associate with source

    sorted sets

    • ‘:aggregate => String`: aggregate function to use (sum, min, max)

Returns:

  • (Integer)

    number of elements in the resulting sorted set



654
655
656
# File 'lib/redis/commands/sorted_sets.rb', line 654

def zinterstore(*args)
  _zsets_operation_store(:zinterstore, *args)
end