advancedTop 30 Scenario-Based Questions

How would you implement a 'Recently Viewed Products' feature for e-commerce?

Redis List per user: 1) On product view: LPUSH views:user:{userId} {productId}. 2) Keep only last 20: LTRIM views:user:{userId} 0 19 (after every push). 3) Retrieve: LRANGE views:user:{userId} 0 19. 4) TTL: EXPIRE views:user:{userId} 604800 (7 days). 5) Display: fetch product details for each ID using pipeline: pipeline.get('product:'+id) for all IDs in one round trip. 6) Deduplication: if you wan

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Design a social media feed system (like Twitter) handling 100M users.← Back to all NoSQL questions