Skip to content

Redis target

TwinCommit keeps Redis in sync with your source database. Each row becomes a Redis hash under a key built from a template, deletes remove the key, and you can also publish every change to a Redis Stream. Caches stay fresh without application code invalidating them.

Supported: Redis 7.x and 8.x · Redis Enterprise and Redis Cloud · Amazon ElastiCache and MemoryDB · Azure Cache for Redis · Valkey.

target:
type: redis
url: rediss://default:${REDIS_PASSWORD}@redis.internal:6380/0
key_template: "{table}:{pk}" # e.g. orders:99812
ttl: 0 # 0 = no expiry
stream: "" # optional: e.g. "cdc:{table}" to also XADD each change
json: false # true = store rows as RedisJSON documents instead of hashes
  • Each source transaction is written in a MULTI/EXEC block per Redis node.
  • Inserts and updates do HSET key field value ... (or JSON.SET), and replace the whole hash so that removed columns disappear.
  • Deletes do DEL key.
  • With stream set, each change is also appended with XADD, including its operation and log position.

The checkpoint is a hash under twincommit:checkpoint:<pipeline>, written in the same MULTI/EXEC block as the data on single-node and replicated deployments. On Redis Cluster, keys span slots, so the checkpoint is written after the batch completes. Writes are idempotent, so a replay after a crash produces the same end state (effectively-once). Stream consumers should deduplicate on the lsn field.

ACL SETUSER twincommit on >******** ~* +@write +@read +multi +exec +@stream -@dangerous