Suyog Kale
Suyog Kale

Reputation: 373

how to get intersect on redis's sorted sets?

I want to display leaders board for the users who are earning more points from two different games.

I am storing user scores as per games using redis's sorted sets, How I can get intersect on these games sorted sets to display common leaderborad.

enter image description here

Upvotes: 1

Views: 455

Answers (1)

Itamar Haber
Itamar Haber

Reputation: 49942

This sounds like a job for ZINTERSTORE:

ZINTERSTORE leaders-sorted-set 2 game-1-sorted-set game-2-sorted-set AGGREGATE SUM

Since there is no AVG aggregate subcommand, you'll have to divide the resultant scores to obtain that.

Upvotes: 3

Related Questions