skip to Main Content

I am trying to get a list in reverse score order.

I am using node redis v4.0.1 which no longer supports client.ZREVRANGEBYSCORE

If I try await client.zRangeByScoreWithScores(‘rankings’, ‘-inf’, ‘+inf’);
This produces a list in ascending order.
If I try await client.zRange(‘rankings’, ‘-inf’, ‘+inf’, {
BY: ‘SCORE’,
REV: true,
});
There is an empty list produced.

How do I get a list in reverse score order?

3

Answers


  1. I guess you’re looking for ZRANGEBYSCORE, not the ‘rev’ one.

    So ZRANGEBYSCORE -inf +inf

    Login or Signup to reply.
  2. Try doing the following:

    await client.zRange('rankings', '+inf', '-inf', { BY: 'SCORE', REV: true, });
    

    When I checked out the documentation, you should switch min and max if you set REV to true.

    Login or Signup to reply.
  3. node redis v4.0 and the above version we use as below.

    client.sendCommand(['ZREVRANGEBYSCORE', 'players', '+inf', '-inf', 'WITHSCORES', 'LIMIT', '0', '3']).then(res => {
        console.log(res);
    })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search