Anh Dũng ơi, anh có thể chia sẻ em kinh nghiệm anh sử dụng redis, ngoài việc cache và pubsub ra anh còn dùng làm gì, thiết kế database với redis như nào
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. anh cũng chỉ dùng cache và pubsub thôi em ạ
2. kinh nghiệm dùng redis:
– Chỉ sử dụng khi cần thiết tiết kiệm bộ nhớ
– Dữ liệu thì nên sử dụng messagepack hoặc protobuf để serialize và deserialize để giảm thiểu dung lượng gói tin
– Redis là NoSQL nên không có join
3. Thiết kế dữ liệu:
– Vì không có join nên mọi dữ liệu đều phải ở dạng key-value, vậy nên thay vì tổ chức thành quá nhiều bảng thì nên gom lại thành ít bảng hơn để truy xuất nhanh hơn. Ví dụ em có 2 bảng trong db kiểu user (userId, email), user metadata (userId, name, nickName) thì giờ em gom lại thành 1 bảng duy nhất trong redis là: user info (userId, email, name, nickName), như thế truy xuất 1 lần sẽ nhanh hơn.