how to do a trending list of posts that a user has not seen already

29 Views Asked by At

no sure if Redis has something for this, or maybe its an engineering problem? if its the latter, then let me know.

I have a sorted list of userPosts. its sorted by the number of upvotes its has. therefore, the order of a userPost within the sorted set can change (every 5 mins)

I have a dictionary to track the posts that a user has seen already. I need to get the first 20 highest voted posts that the user has never seen before.

Whats an efficient way to do this?

If i fetch the 20 highest posts. I can add them to the already seen dictionary. now after 5 mins, the list order is updated (so i cant use indexes), If i fetch another 20 posts, some will be seen and others unseen. And i can filter it. All good.

but if another 5 mins goes by, then 10, then 20, etc and the user keeps coming back, eventually the loop which does the filtering will continue to increase making the loop inefficient.

Is there some way to fetch the highest 20 posts that the user has never seen before? I am using REDIS, but if i can get a description of the solution in general terms i'll be ok.

0

There are 0 best solutions below