<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/building-a-recently-viewed-products-tracker-with-redis-sorted-sets-0uilwtlco" -->

---
title: Building a Recently Viewed Products Tracker with Redis...
description: A practical walkthrough of implementing a recently-viewed-products feature in a Laravel storefront using Redis sorted sets instead of a database table with...
canonical: https://daily.dev/posts/building-a-recently-viewed-products-tracker-with-redis-sorted-sets-0uilwtlco
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building a Recently Viewed Products Tracker with Redis Sorted Sets | daily.dev
og:description: A practical walkthrough of implementing a recently-viewed-products feature in a Laravel storefront using Redis sorted sets instead of a database table with...
og:url: https://daily.dev/posts/building-a-recently-viewed-products-tracker-with-redis-sorted-sets-0uilwtlco
og:image: https://api.daily.dev/og/posts/0uILWtLcO.png
og:image:alt: Building a Recently Viewed Products Tracker with Redis Sorted Sets
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a Recently Viewed Products Tracker with Redis Sorted Sets

**[PHP Architect](https://daily.dev/sources/phparchitect)** · [@shocm](https://daily.dev/shocm) · 1 min read · 2 upvotes · 1 comments

## Summary

A practical walkthrough of implementing a recently-viewed-products feature in a Laravel storefront using Redis sorted sets instead of a database table with timestamps and cleanup jobs. Covers why sorted sets fit the ordered, capped, high-write nature of the feature and how to wire it into Laravel.

## Content

"Recently viewed products" is one of those features that looks trivial until you think about scale: every page view is a write, the list needs to be ordered by recency, capped in length, and fast to read. A database table with timestamps and a cleanup job works, but Redis sorted sets are built for exactly this shape of problem. Here is how to build it in a Laravel storefront.

https://laravelmagazine.com/building-a-recently-viewed-products-tracker-with-redis-sorted-sets

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 2 upvotes

> I'd use a keyed hash before a `crc32` collision mixes two people's history

## Similar posts on daily.dev

- [System Design Drill Day 8: Distributed Locks with Redis and Fencing Tokens](https://daily.dev/posts/system-design-drill-day-8-distributed-locks-with-redis-and-fencing-tokens-8ssctjtpn) · C\# Corner · 3 upvotes · 1 comments
- [Pruning Abandoned Carts](https://daily.dev/posts/pruning-abandoned-carts-gaa6lepzw) · Larablog · 0 upvotes · 0 comments

---

Tags: [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel), [#redis](https://daily.dev/tags/redis)

[View this post on daily.dev](https://daily.dev/posts/building-a-recently-viewed-products-tracker-with-redis-sorted-sets-0uilwtlco)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/building-a-recently-viewed-products-tracker-with-redis-sorted-sets-0uilwtlco","headline":"Building a Recently Viewed Products Tracker with Redis Sorted Sets","text":"A practical walkthrough of implementing a recently-viewed-products feature in a Laravel storefront using Redis sorted sets instead of a database table with timestamps and cleanup jobs. Covers why sorted sets fit the ordered, capped, high-write nature of the feature and how to wire it into Laravel.","url":"https://daily.dev/posts/building-a-recently-viewed-products-tracker-with-redis-sorted-sets-0uilwtlco","datePublished":"2026-09-08T22:01:56.654Z","dateModified":"2026-09-13T20:47:40.691Z","author":{"@type":"Person","name":"Eric Johnson","url":"https://daily.dev/shocm","image":"https://media.daily.dev/image/upload/s--EPMJ-a-K--/f_auto/v1755890250/avatars/avatar_y7ct3dSEp45NFSALYHve6?_a=BAMClqZW0","description":"PHP Architect team member. I am powered by 16-year-old single malt Scotch and baseball.","worksFor":{"@type":"Organization","name":"php[architect]","logo":"https://res.cloudinary.com/daily-now/image/upload/s--10MwB_VH--/f_auto/v1726147436/companies/phparch"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":450}},"image":"https://media.daily.dev/image/upload/s--L8ch03DM--/f_auto/v1788904916/posts/0uILWtLcO?_a=BAMAMicg0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"comment":[{"@type":"Comment","text":"I’d use a keyed hash before a crc32 collision mixes two people’s history","datePublished":"2026-09-19T15:53:33.306Z","url":"https://daily.dev/posts/0uILWtLcO#c-OK3uv6jOH","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/phparchitect","name":"PHP Architect"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"PHP Architect","item":"https://daily.dev/squads/phparchitect"},{"@type":"ListItem","position":3,"name":"Building a Recently Viewed Products Tracker with Redis Sorted Sets"}]}
```

