Answer the question
In order to leave comments, you need to log in
How to organize the marking of "viewed" materials?
Using YouTube as an example:
I watched a video, and now I want this video to always be marked as "watched". That is, my history must be saved somewhere. But what if I have been using YouTube for a long time and managed to watch 10 thousand videos? How does YouTube mark videos that have been watched?
I have node.js server, react.js+flux front and PG subd.
Here's what came to mind:
The story is overloaded with unnecessary information - when I looked at the name of the video, etc. This infa is needed for other cases. I will do a search and pull from PG only the uuid of all the videos watched. I will translate it into an array form and send it to the client side. The client will store all this in localStorage and mark it with a date so that from now on the server will give only the missing part of the history. When rendering those pages that need to be marked as "watched videos", I will get the locally stored history and use the simplest way to check:
if(arrayWithAllWatchedVideosUUIDs.indexOf(currentVideoUUID) !== -1) {
пометить как "просмотренно"
}
Answer the question
In order to leave comments, you need to log in
I would not use sql for these purposes at all. This is data that, basically: is temporary, limited (100/1000/10000 records, etc.), does not affect the main functionality, can be counters, there can be a lot of them, it would be nice to extract them very quickly, using them no need to do a lot of processing, they have a "lifetime" ...
Therefore, I suggest looking towards redis.io which is created for this!
Serial:
- id
- name
- ....
Series
- id
- series = ForeignKey(Series)
User
- id
- name
- ....
- series = ManyToMany(Series)
https://en.wikipedia.org/wiki/ Many-to-many_(data_model)
If you don't need aggregation by users, view counters, or if you need consistency, then you replace ManyToMany with a list of series IDs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question