[System Design and Optimization] The article praised the optimization of information

  mysql, question

There is a list of articles, and each time the page is paged (10 pieces of data per page), the user needs to check whether the user has clicked the praise when logging in.

 HasPraised:boolean// has it been praised

The table structure is as follows:

Table article:{// article table
 Id:BIGINT// self-increasing id
 //other attributes
 Table praise
 Id:BIGINT// self-increasing id
 Article_Id:BIGINT// article id
 User_Id:BIGINT// user id
 Create_time:DATETIME// creation time

At present, mysql is checked in real time, and whether the user has praised or not is queried according to praise table.
I don’t know how to optimize and improve the response speed of the interface.

PS: If redis is used, please note that the current project does not support redis persistence and is only used as cache.

Redis is used as cache.

key: userid
value: set(articleid)

When the user logs in, check redis once. If redis does not exist, query mysql and update redis
When users praise, insert mysql and update redis at the same time