vpe4ra
Last Updated: February 25, 2016
·
4.428K
· artchang

Trim redis sorted sets to a max number

If you have a leaderboard or just want to save a specific number of the highest scored sets in a sorted set, use ZREMRANGEBYRANK. The example below will only keep the top 100 highest scored items:
ZREMRANGEBYRANK key 0 -100

1 Response
Add your response

10466

Off by one; to keep the top 100 you must do:

ZREMRANGEBYRANK key 0 -101</code>

over 1 year ago ·