vpe4ra
Last Updated: February 25, 2016
·
3.802K
· artchang
Photo sep 26  14 31 57

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

Say Thanks
Respond

1 Response
Add your response

10466
9462a5498a20fe5a7258f9a9a2f3c66b

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

ZREMRANGEBYRANK key 0 -101</code>

over 1 year ago ·
Awesome Job

E7334122 1780 11e8 9aaf caa9487f1cb0
DevOps Engineer
·
Negotiable, Sydney or Canberra pref
·
Full Time