伊谢尔伦2017-04-18 09:41:45
Determine the uniqueness of likes based on IP, device number or some unique identifier, use a cache such as redis to update, and then write it to the database asynchronously and synchronously. If the liker is notified asynchronously, the click will be treated as an event and placed in a queue. It can be processed uniformly.
PHP中文网2017-04-18 09:41:45
Lock likes. When sending a request for likes, lock the like button to prevent users from clicking it
Directly feedback users' likes. Users are hard to perceive many details of this very simple operation. For a better user experience, you can directly display +1 the web style when giving a like, and then send a request to the backend. .
The general like operation here is like this:
+=============+ +----------------------------------+
| 用户点赞 | ----> | 直接回馈用户点赞成功 |
| | <---- | 样式+1 |
+=============+ +----------------------------------+
|
|
异步发送点赞请求 -----------------------> 后端接收,数据库完成点赞
PHP中文网2017-04-18 09:41:45
This is concurrency. It is impossible to remove all situations like this. Just introduce caching. Of course, you can do some global measures. If the number of clicks per second exceeds a warning, it will be similar to preventing some crawlers and a single IP. There is a click limit per unit time
巴扎黑2017-04-18 09:41:45
Control the number of clicks, if there are too many clicks, you will be reminded