Skip to main content
PreparationZone Logo
PrepZone

DynamoDB Streams, DAX, and Transactions

Change data capture, microsecond caching, and multi-item ACID writes.

Pass checkpoint below

Why this matters

  • VaultCommerce emits Stream events when order status changes — search index, email, and analytics services react without polling the table.
  • DAX helps read-heavy product-metadata paths but hides stale reads — only cache idempotent, TTL-tolerant data.
  • Checkout must deduct inventory and create an order atomically — TransactWrite with condition checks prevents double-sell.
Partition key: USER#42Routes to shard
Items in partition
ORDER#2026-001Sort key
ORDER#2026-002Sort key
PROFILESort key
Partition key routes to a shard. Sort key orders items within that partition.

DynamoDB Streams

Streams append INSERT, MODIFY, REMOVE records with old/new images. Enable on the table, attach a Lambda event source mapping:

Java
aws dynamodb update-table \
  --table-name VaultCommerce \
  --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES
Java
def handler(event, context):
    for record in event["Records"]:
        if record["eventName"] in ("INSERT", "MODIFY"):
            new_image = record["dynamodb"]["NewImage"]
            if new_image.get("SK", {}).get("S", "").startswith("ORDER#"):
                sync_to_elasticsearch(unmarshall(new_image))

Stream view types

  • KEYS_ONLY — partition and sort keys only.
  • NEW_IMAGE — item after change.
  • OLD_IMAGE — item before change.
  • NEW_AND_OLD_IMAGES — both — VaultCommerce uses this for audit diffs.

Consumers must be idempotent — Lambda retries duplicate events.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 2 sections

  • DAX caching layer
  • TransactWriteItems

Test yourself

Answer these before moving on — recall is what makes it stick.