I think of two ways:
1. Get the data in the most recent period, and return the data if there is any; but this time period is not easy to set. Chrome can use the last 3 seconds, but Firefox uses the last 5 seconds, so take 3 seconds If so, Firefox often cannot retrieve it; if it takes 5 seconds, Chrome will retrieve duplicate data.
2. The second idea is to mark whether it is read in the database, but because different browsers and different terminals get data out of sync, one of them will mark it as read after getting the data, and other browsers will not be able to get it. Data.
So, how should we deal with it?
I think of two ways:
1. Get the data in the most recent period, and return the data if there is any; but this time period is not easy to set. Chrome can use the last 3 seconds, but Firefox uses the last 5 seconds, so take 3 seconds If so, Firefox often cannot retrieve it; if it takes 5 seconds, Chrome will retrieve duplicate data.
2. The second idea is to mark whether it is read in the database, but because different browsers and different terminals get data out of sync, one of them will mark it as read after getting the data, and other browsers will not be able to get it. Data.
So, how should we deal with it?
The second idea is possible, but it needs to be optimized. You can store the update time of the data in the table memory and the update time of the latest data obtained from the server in the terminal. If the terminal time is smaller than the table time, it means there is new data to be pushed.