Q
Q
Quber2015-01-27 16:48:24
PHP
Quber, 2015-01-27 16:48:24

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

3 answer(s)
D
Dmitry Entelis, 2015-01-27
@Quber

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)

V
Vyacheslav, 2015-01-27
@hedint

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.

I
IceJOKER, 2015-01-27
@IceJOKER

If for guests, then cookies or sessions are better, just exclude viewed ones when outputting -

WHERE `id` NOT IN (implode(',', $_SESSION['saw_id_list']));

it is desirable to filter before the request -
$saw_id_list = array_map(intval, $_SESSION['saw_id_list']);

And if the system is with authorization, then we store it in the database, you can clean the table once a month

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question