Answer the question
In order to leave comments, you need to log in
How to organize data selection in Redis by date?
It is necessary to store the number of views by time interval, so that it would be possible to choose for: the last 24 hours, 30 days and half a year.
So far, there is one option: to do it according to the “users online” principle, but if you do, for example, an hourly interval (time() // 3600) for 30 days, you get ~ 720 keys per entity.
Maybe someone has already done this? What other options are there?
Answer the question
In order to leave comments, you need to log in
You can push all data on views into one value, each 4 bytes of which will contain the number of visits in one day - and work with them through GETBIT / SETBIT.
the solution is simpler - sorted set
key - <name>_<date>_<hour>, value - number, added via zadd
in the case of setbit, locks will be needed, as far as I understand. with zadd -
old statistics are not needed, you can throw them into the database, for example
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question