#114 Recently viewed products with Kredis

24/02/2023
kredis Coding Recently viewed products E-commerce Database Data caching Gem Kredis Kredis unique

Recently viewed products is a very common feature in Ecommerce.
Showing users a list of products they viewed is considered to increase conversion.
The least complex way of implementing this kind of list can be in Redis.
Gem Kredis allows us to associate a Redis attribute with an ActiveRecord model.
We will store and update the list of recently visited products in Redis and associate it with our Current user.

Episode source code: https://github.com/corsego/114-kredis-recently-viewed-products/commit/22cfd31ad68bbb67ebf3b5f57b976b2dff5f6d7a
Blogpost - kredis recently visited pages: https://blog.corsego.com/kredis-recently-visited-pages

0:00 Store recently visited in Redis vs Postgresql?
1:58 Kredis unique list
2:50 Add kredis attribute to User
4:00 Update recently_viewed_products
5:25 display users recently_viewed_products
7:25 Works! We can now store and display a list of 5 most recently visited products by the user

1
Join the conversation
Sign in to access PRO lessons, access private repos, leave comments, create watch lists.
We collect your email address, name and username to create your account. We do not share your email address with anyone else.