java - web应用中如何避免频繁点赞操作,比如点击又取消又点击如此循环?
巴扎黑
巴扎黑 2017-04-18 09:39:45
0
5
1044
巴扎黑
巴扎黑

reply all(5)
伊谢尔伦

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.

洪涛
  1. Lock likes. When sending a request for likes, lock the like button to prevent users from clicking it

  2. 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               |
+=============+        +----------------------------------+
                                      |                                
                                      |
                             异步发送点赞请求 -----------------------> 后端接收,数据库完成点赞
洪涛

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

伊谢尔伦

Remove the button after liking it

巴扎黑

Control the number of clicks, if there are too many clicks, you will be reminded

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template