sorting - redis sort by multi fields -
it's easy use sql query multi sort fields.for example:
select * user order score desc,name desc
with 2 fields sort(score,name).
how should in redis?
use sorted set of redis sorted score. have prepare score according needs.
finalscore = score*max_name_value + getintrepresentation(name) //max_name_value maximum value returned getintrepresentation() method
and use
zadd myset finalscore value
and use
zrevrange myset 0 10
Comments
Post a Comment