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
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
How would you implement a 'Recently Viewed Products' feature for e-commerce?