Command Palette

Search for a command to run...

PHASE 8Intermediate ~6 min· topic 9 of 10

Topic 8.9

Key-Value Databases

In one line

DynamoDB/Redis-class stores: O(1) by key, insane scale, and the access patterns that justify them.

0/10 · 0%

Think of it like this

A cloakroom at a wedding: you hand over your coat and get a numbered tag. Getting your coat back later is just 'tag number → coat', instant and simple, with no other questions asked.

Key ideas

  1. 01

    Contract: get(k)/put(k,v) — everything else is apps' business.

  2. 02

    DynamoDB: partition key + optional sort key = built-in, automatic sharding; GSI/LSI for secondary access.

  3. 03

    Redis: in-memory with rich value types (strings, hashes, sets, sorted sets, streams) + TTL — s̶t̶o̶r̶e̶ cache + session + counter.

  4. 04

    Sorted sets = leaderboards/feeds; streams = light queues; TTL = sessions; the 'cache with a pulse' profile.

  5. 05

    Eventual vs strong: DynamoDB default is eventual reads (strongly consistent is opt-in and costs).

  6. 06

    Interview line: 'this is a key-value access pattern: user preferences by user_id — DynamoDB/Redis, one get'.

Java / Spring map

  • →

    spring-data-redis (RedisTemplate, Bucket4j for rate limiting), AWS SDK DynamoDbClient.

Explain without notes

01

Leaderboard 'top 100 by score' — which Redis structure answers it without a scan?

Practice

01

Design session store (TTL), rate-limit counter, and a fan-out queue with redis structures.

Trade-offs

  • ↔

    Key-value wins by surrendering queries — every new access pattern is a new key design.

Run it in production

Completion checklist

  • I can spot the key-value pattern in a prompt and name the store.

Back to phase