how to get intersect on redis's sorted sets?

454 views Asked by At

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

1

There are 1 answers

2
Itamar Haber On

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.