To make a comment system, each article corresponds to an aid, and there are comments below. There are two solutions for storing these comments. 1 is separate storage, and each comment has to be given to cid, which is a hashcommentinfo: $ cid {cid: $ cid, time: XXX. author: xxx ......}. Each article has a setcommentl... to make a comment system,
Each article corresponds to an aid, and there are comments below,
There are two solutions to store these comments
1 is stored separately. Each comment is sent to cid, which is a hash commentinfo: $ cid {cid: $ cid, time: XXX. author: xxx ......}. Each article has a set commentlist: $ aid [cid1, cid2, cid3.].
2. Each article has an sort set conmentlist: $ aid. score is the timestamp, and value is a complete json data string.
Which storage method is better?
Reply content:
To make a comment system,
Each article corresponds to an aid, and there are comments below,
There are two solutions to store these comments
1 is stored separately. Each comment is sent to cid, which is a hash commentinfo: $ cid {cid: $ cid, time: XXX. author: xxx ......}. Each article has a set commentlist: $ aid [cid1, cid2, cid3.].
2. Each article has an sort set conmentlist: $ aid. score is the timestamp, and value is a complete json data string.
Which storage method is better?
Second, less data is transmitted
It is not better to directly use List, so that each insert is a single piece of data. You can select the range segment and the total number to achieve the page flip function. The details are as follows:
Use comments: id as the key, use lpush to press data, and use lrange to take values.