Answer the question
In order to leave comments, you need to log in
How to not display the content viewed by the user on the user's feed?
It is necessary to track the "wall" of the user (ala VKontakte) and not display information on it that he has already seen.
How to implement it correctly?
Thought about assigning cookies, but here's the thing, if he views 50,000 items, that many cookies probably won't even fit.
Or with localstorage, but then the content that the user should not see will still be generated on the server, that is, doing an extra operation, which is not good.
An option to store all this information in the database, but then what if there are millions of records, how will this affect read and write performance?
Are there any suitable alternatives?
Answer the question
In order to leave comments, you need to log in
The task is really difficult :)
I would think if you really need it.
The decision in a forehead: to store a plate user_id, post_id - the information which the user looked.
But we need to somehow filter the post_id on the output - the ambush is that the view query select ... from post where post_id not in ( ... )
does not use an index and is therefore extremely slow.
I don’t know of normal solutions that work for tens of thousands of users / posts, all have at best the capacity of count (user) * count (post)
You have yet to highlight the "viewed" state. :)
The fact that something was brought to me somewhere does not mean that I looked through it.
Specifically on the issue - of course, save in the database.
Cookies are changed / deleted, localstorage - too.
If for guests, then cookies or sessions are better, just exclude viewed ones when outputting -
WHERE `id` NOT IN (implode(',', $_SESSION['saw_id_list']));
$saw_id_list = array_map(intval, $_SESSION['saw_id_list']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question