Sorting redis按多字段排序
使用sql查询多排序字段很容易。例如:Sorting redis按多字段排序,sorting,redis,Sorting,Redis,使用sql查询多排序字段很容易。例如: select * from user order by score desc,name desc 使用两个字段排序(分数、名称) 在redis中应该如何做到这一点?使用按分数排序的redis排序集。你必须根据自己的需要准备分数 finalScore = score*MAX_NAME_VALUE + getIntRepresentation(name) //MAX_NAME_VALUE is the maximum value returned by g
select * from user order by score desc,name desc
使用两个字段排序(分数、名称)
在redis中应该如何做到这一点?使用按分数排序的redis排序集。你必须根据自己的需要准备分数
finalScore = score*MAX_NAME_VALUE + getIntRepresentation(name)
//MAX_NAME_VALUE is the maximum value returned by getIntRepresentation() method
然后使用
zadd myset finalScore value
以及正确的使用方法
zrevrange myset 0 10