E
E
Eugene2015-01-24 10:58:26
MySQL
Eugene, 2015-01-24 10:58:26

What is the best way to implement the output of popular posts in 24 hours?

The popularity of a post is determined by the number of views it has.
It is necessary to display it with a sliding window for 24 hours.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vapaamies, 2015-01-24
@vapaamies

Well ... like in science fiction films, apparently. You need to say in a voice: "Base, bring me popular entries in 24 hours." If the base is American, it's better to speak English, I think.

Y
Yuri Shikanov, 2015-01-24
@dizballanze

Look towards Sorted sets Redis.

A
Alex Pts, 2015-01-25
@AlexPTS

Or simplify the task and throw out the concept of "floating", then this is a simple sorted set out of the box.
Otherwise, for each post, as an option, create a list and store each access time in it.
When viewing, read the entire list, from the end or beginning (how to store) delete everything that is more than 24 hours. The length of list will be a valid number of views over a floating 24 hours. But with a lot of views and a lot of posts, this option is most likely not very attractive.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question