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 sink

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

Configure the source

1

Select source table

Under “Source”, select the table you want to stream data from.

2

Choose message type

Specify whether you want to receive changes or rows from the table.

If you’re not sure which to choose, you can start with the default, “Changes”.

3

Specify filters

If you selected changes, in “Records to process”, you can indicate whether you want to receive insert, update, and/or delete changes.

You can also specify SQL filters to narrow down the events you want to receive. For example, if you only want to receive events for subscriptions that currently have an mrr greater than $100, you can add a filter on mrr > 100.

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

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 Sink”.

Verify & debug

To verify that your Redis 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 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 sinks work, see the Redis sink reference.

Was this page helpful?