# #114 Recently viewed products with Kredis

- URL: https://superails.com/posts/rails-7-114-recently-viewed-products-with-kredis
- Published: 2023-02-24
- Duration: 08:02
- Access: free
- Topics: 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

## Chapters

- 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
