Redis storage user comment

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.