This guide shows you how to set up Postgres change data capture (CDC) and XADD changes to a Redis stream using Sequin.

With Postgres data streaming to Redis, you can trigger workflows, keep services in sync, build audit logs, maintain caches, and more.

By the end of this how-to, you’ll have database changes flowing to a Redis stream.

Prerequisites

If you’re self-hosting Sequin, you’ll need:

  1. Sequin installed
  2. A database connected
  3. A Redis instance ready to go

If you’re using Sequin Cloud, you’ll need:

  1. A Sequin Cloud account
  2. A database connected
  3. A Redis instance ready to go

Create Redis Stream sink

Navigate to the “Sinks” tab, click “Create Sink”, and select “Redis Stream Sink”.

Configure the source

1

Select source tables

Under “Source”, select the schemas and tables you want to stream data from.

2

Add filters (optional)

Add filters to the sink to control which database changes are sent to your Redis stream.

3

Add transform (optional)

Add a transform to the sink to modify the payload before it’s sent to Redis.

4

Specify backfill

You can optionally indicate if you want Redis to receive a backfill of all or a portion of the table’s existing data. Backfills are useful if you want to use Redis to process historical data.

You can backfill at any time. If you don’t want to backfill, toggle “Backfill” off.

5

Specify message grouping

Under “Message grouping”, you’ll most likely want to leave the default option selected to ensure events for the same row are sent to Redis in order.

Configure Redis Stream

1

Enter Redis connection details

Fill in your Redis connection details:

  • Host (required): The hostname of your Redis server
  • Port (required): The port number (1-65535)
  • Stream key (required): The name of the stream where messages will be published (max 255 characters)
  • Username: Redis username for authentication (optional)
  • Password: Redis password for authentication (optional)
  • Database: Redis database number (optional, defaults to 0)
  • TLS: Enable TLS/SSL encryption for the connection (optional, defaults to false)
2

Create the sink

Give your sink a name, then click “Create Redis Stream Sink”.

Verify & debug

To verify that your Redis Stream sink is working:

  1. Make some changes in your source table
  2. Verify that the count of messages for your sink increases in the Sequin web console
  3. Using Redis CLI or another Redis client, check your stream:
    xread count 10 streams your-stream-key 0
    
    You should see the messages from Sequin appear in the stream.

If messages don’t seem to be flowing:

  1. Click the “Messages” tab to view the state of messages for your sink
  2. Click any failed message
  3. Check the delivery logs for error details, including any Redis connection errors

Next steps

  • Setup a processor

    Now that your Postgres data is flowing into Redis, you can setup a processor to read from the stream and process the data. See the Redis docs on XREAD.

    Refer to the Redis Stream sink reference for the shape of messages that Sequin will publish to Redis.

  • Deploy your implementation

    When you’re ready to deploy your implementation, see “How to deploy to production”.

  • Advanced configuration

    For more about how Redis Stream sinks work, see the Redis Stream sink reference.