Redis Stream Activity Feed | Christopher Vachon

Redis Stream Activity Feed

2022-10-29

I recently built a demo project for the purpose of testing the usage of Redis as an activity feed of recent changes to a system. As the project this proof of concept already uses Redis in multiple capacities, we wanted to try to utilize it in this capacity to maintain the current dependency stack.

Redis Stream

I chose to use Redis Streams for multiple reasons:

  1. I can set a Maximum Length of the Stream.
  2. I select from the last ID natively with the Stream.
  3. A Redis Stream is Optimized for this exact use case.

The Project Overview

The project itself is in NextJS utilizing a single  API endpoint for the Redis Connection. I set up a POST action to add a new record to the Stream and a GET method to retrieve the latest items of the feed. A simple interface was developed to interact with the feed through the API endpoint.

You can check out the full concept project here: @CodeVachon/feed-testing