Module cdc

Module cdc 

Source
Expand description

Change Data Capture (CDC) Stream support.

Emits mutations to a Redis Stream for external replication agents. The stream key is {redis_prefix}__local__:cdc where __local__ indicates node-local infrastructure that should not be replicated itself.

§Stream Format

§PUT operation

XADD {prefix}__local__:cdc MAXLEN ~ 100000 *
  op    "PUT"
  key   "uk.nhs.patient.12345"
  hash  "a1b2c3..."                # content_hash for dedup
  data  <zstd(content)>            # compressed payload
  meta  '{"content_type":"json","version":3,"updated_at":1735776000000}'

§DELETE operation

XADD {prefix}__local__:cdc MAXLEN ~ 100000 *
  op    "DEL"
  key   "uk.nhs.patient.12345"

§Compression Strategy

Data is zstd-compressed before writing to the stream, unless it already has zstd magic bytes (to avoid double-compression).

Structs§

CdcEntry
A CDC entry ready to be written to the stream
CdcMeta
Metadata for CDC PUT entries

Enums§

CdcFieldValue
Field value types for CDC entries
CdcOp
CDC operation type

Constants§

CDC_STREAM_SUFFIX
CDC stream suffix (appended to redis_prefix)

Functions§

cdc_stream_key
Build the full CDC stream key from an optional prefix
is_zstd_compressed
Check if data appears to be zstd-compressed
maybe_compress
Compress data with zstd, unless it’s already zstd-compressed.
maybe_decompress
Decompress zstd data if it has the magic header, otherwise return as-is.