• Shopee đêm nay có mã cho ngày 5/5

thảo luận Hỏi về redis cache ??

Taiuou

Junior Member
Viết tiếng Việt tử tế đi
Chào mọi người e 2k là newbie e đang làm một dự án microservice theo pattern cqrs.
  • Cmd side e cho write vô mysql và bắn event qua kafka.
  • Read side e dùng mongo để projection và hạn chế gọi internal call giữa các read side và e có dùng redis cache.
-Hạn chế rest api của e gọi tk getuser(userId,(jwt )requestUserId) để trả về user có field mutual_friend vs relationship_status -> Thì em có 2 hướng:
1. Cache key: user:{userId}: value: list friends -> r hit cache 2 lần rồi tính toán -> trả về response.
2. Cache key là user:{userId}:{requestUserId} : value: list mutual friends của 2 users -> hit r trả về response luôn.
- Em thâý Cách thứ 2 khi xảy ra sự thay đổi thông tin ở command side thì update cache rất mệt. mn cho e giải pháp vs
 
Last edited:
Câu hỏi Tiếng Việt mà đọc khó quá. Câu hỏi về cache structure thì thường level senior quyết định chứ 2k1 lại newbie thì làm gì có kinh nghiệm kiến thức mà làm.
 
Chào mọi người e 2k là newbie e đang làm một dự án microservice theo pattern cqrs.cmd side e cho write vô mysql và bắn event qua kafka.Read side e dùng mongo để projection và hạn chế gọi internal call giữa các readside và e có dùng redis cache.chả hạn rest api của e gọi tk getuser(userId,(jwt )requestUserId) để trả về user có field mutual_friend vs relationship_status thì e nên cache user:{userId} user:{requestUserId} r hit cache 2 tk rồi tính toán trả về response hay cache user:{userId}:{requestUserId} hit r trả về response luôn cách thứ 2 khi command side của update cache rất mệt mn cho e giải pháp vs
tôi nghĩ b nên viết ra mấy gạch đầu dòng cho dễ nhìn ==" viết kiểu này khó hiểu
 
Chào mọi người e 2k là newbie e đang làm một dự án microservice theo pattern cqrs.cmd side e cho write vô mysql và bắn event qua kafka.Read side e dùng mongo để projection và hạn chế gọi internal call giữa các readside và e có dùng redis cache.chả hạn rest api của e gọi tk getuser(userId,(jwt )requestUserId) để trả về user có field mutual_friend vs relationship_status thì e nên cache user:{userId} user:{requestUserId} r hit cache 2 tk rồi tính toán trả về response hay cache user:{userId}:{requestUserId} hit r trả về response luôn cách thứ 2 khi command side của update cache rất mệt mn cho e giải pháp vs
phím enter hư rồi hả thím
 
Chào mọi người e 2k là newbie e đang làm một dự án microservice theo pattern cqrs.
  • Cmd side e cho write vô mysql và bắn event qua kafka.
  • Read side e dùng mongo để projection và hạn chế gọi internal call giữa các read side và e có dùng redis cache.
-Hạn chế rest api của e gọi tk getuser(userId,(jwt )requestUserId) để trả về user có field mutual_friend vs relationship_status -> Thì em có 2 hướng:
1. Cache key: user:{userId}: value: list friends -> r hit cache 2 lần rồi tính toán -> trả về response.
2. Cache key là user:{userId}:{requestUserId} : value: list mutual friends của 2 users -> hit r trả về response luôn.
- Em thâý Cách thứ 2 khi xảy ra sự thay đổi thông tin ở command side thì update cache rất mệt. mn cho e giải pháp vs
Diễn đạt giùm thèng thớt. Thớt vô kiểm tra xem đúng ý ko ? Hại não vl
 
Last edited:
đăng từ 4h sáng mà giờ vẫn ko thấy mặt mũi đâu
yPXIBxC.png
 
Câu hỏi Tiếng Việt mà đọc khó quá. Câu hỏi về cache structure thì thường level senior quyết định chứ 2k1 lại newbie thì làm gì có kinh nghiệm kiến thức mà làm.
Dạ mới nhú phải lao đầu vào bụi rậm chớ a hihi :too_sad::too_sad:
 
Cách 2 của bạn phải có 2 duplicate key value vì 2 users có thể đổi role cho nhau.

Nếu không muốn duplication thì làm kiểu 1 key point vào key còn lại
 
Back
Top