2 ms·
Guys how do I paginate volatile ranking?
Since we're on hackernews anyone know how one paginate a volatile list of threads like on hackernews?
If the ranking score changes, mostly when a thread on the next page has its ranking boosted, it results in a missed result if I use a naive cursor pagination. Any ideas and would be great if anyone know how hackernews or reddit does it in production.
Thanks :O
- verdverm 7y agoI'd calculate some ranking, every X seconds, keep it in a cache of some sort, and page from that. They do seem to persist it permanently too, because you can go view the top list on a given day. Also notice new works like traditional cursor paging, while the front/main thread ranks like you describe. The hiding feature is another interesting one to think about w.r.t. paging. Have you inspected the network requests and responses?
- o____o 7y agoOmg you just got me thinking! I am already planning on using Redis for this board. What I could do is keep 1 main copy of my leaderboard, that is used mainly for writes, then I also keep other copies of the leaderboard but in snapshots of previous 30 seconds, 1 minute, 1:30 etc. This way depending on when you first queried for the initial page, you access copy of the leaderboard at X time. One edge case I'm not sure about is what I should do if user has a pointer to a very old copy of the leaderboard, lets say >30 minutes or >1 hour, it would be kind of expensive to keep so many copies (or maybe not?).