【问题标题】:redis v4 list sorted in reverse orderredis v4列表以相反的顺序排序
【发布时间】:2022-06-11 01:34:51
【问题描述】:

我正在尝试以相反的分数顺序获取列表。

我正在使用不再支持 client.ZREVRANGEBYSCORE 的 node redis v4.0.1

如果我尝试 await client.zRangeByScoreWithScores('rankings', '-inf', '+inf'); 这会按升序生成一个列表。 如果我尝试 await client.zRange('rankings', '-inf', '+inf', { BY:'得分', 修订:是的, }); 产生了一个空列表。

我如何以相反的分数顺序获得列表?

【问题讨论】:

    标签: node.js redis nestjs


    【解决方案1】:

    我猜你正在寻找ZRANGEBYSCORE,而不是“rev”。

    所以ZRANGEBYSCORE -inf +inf

    【讨论】:

    • 我不认为你可以用ZREVRANGEBYSCORE得到相同的输出
    【解决方案2】:

    尝试执行以下操作:

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

    当我查看文档时,如果您将 REV 设置为 true,您应该切换 min 和 max。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-13
      • 2013-08-07
      • 2012-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-13
      • 1970-01-01
      相关资源
      最近更新 更多