Answer the question
In order to leave comments, you need to log in
How to count the news for the user?
In continuation to the question: How to hide news from the user's feed?
Briefly: in order not to load too much, I will give an analogy from VK. There are publics, the user subscribes to them and he displays news, the problem is that the user must have a counter for these news (my news is +6)
Of course, if I manually increase the counter for everyone who is subscribed to the public, it will be very expensive , there can be many users.
How to organize the solution of this problem in the best way?
Answer the question
In order to leave comments, you need to log in
I would implement through the ID of the last read news in the session of the user, when creating the news, I would update the field in the variable table.
further SELECT ID FROM var
(it will be perfectly cached and will be given instantly), in the code itself we subtract the last ID from the current one - profit.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question