This is the how-to guide for streaming Postgres to Redis Strings. See the quickstart for a step-by-step walkthrough or the reference for details on all configuration options.
Prerequisites
To follow this guide, you need:- A running Redis instance
- Sequin installed and configured
- A Postgres database connected to Sequin
Create a Redis String sink
1
Navigate to Sinks
In the Sequin web console, go to Sinks → Create sink → Redis String.
2
Configure the source
Under Source:
- Select the database and table or schema you want to cache
- Choose which actions to capture (
insert
,update
,delete
). You likely want to cache all actions - Optionally add filters to cache only specific rows
3
Set up initial backfill
Toggle Initial backfill if you want to initialize your Redis cache with all of the current data in your Postgres table.You can choose to backfill again later via the Sequin web console or the management API.
4
Create a transform
Create a transform to define how your Postgres data is stored in Redis. The most common transform is to store the entire record as a JSON object:For more selective caching, you can transform the data structure before storing it in Redis. For example, to cache only a few fields:
5
Configure Redis connection
Enter your Redis connection details:
- Host: Your Redis server address (e.g.,
localhost
orredis.example.com
) - Port: Redis port (default:
6379
) - Username/Password: If authentication is enabled
- Database: Redis database number (default:
0
) - TLS: Enable if your Redis server uses TLS
- Expire MS: Optional expiration time in milliseconds for cached keys
6
Test and create the sink
- Click Test Connection to verify Redis connectivity
- Name your sink (e.g.,
products-cache
) - Click Create Sink
Understanding key formats
By default, Sequin uses this key format in Redis:-
(ie. sequin:products:42-123
).
Verify your cache is working
- Check that data is flowing by watching the Messages tab in the Sequin console
-
Query Redis to see your cached data:
- Make a change in your Postgres database and verify it appears in Redis
Common caching patterns
Cache invalidation
Redis Strings sink automatically handles cache invalidation:- Inserts and updates result in
SET
operations - Deletes result in
DEL
operations
TTL-based caching
Setexpire_ms
to automatically expire keys after a specific period:
expire_ms: 86400000
=> 24-hour cacheexpire_ms: 3600000
=> 1-hour cache
delete
actions are enabled in the sink configuration.