NoSQL & Cache

Every system in this course leans on one truth: the fastest query is the one you never run. Redis makes state fast; document databases make state flexible. The last two tools in the belt.

▶ Watch this reel

What you'll learn

  1. Redis: memory-speed state
  2. Redis as infrastructure
  3. Document databases
  4. Choosing your store

Remember this

Redis

Document DBs (MongoDB / Cosmos DB)

Storage policy

Postgres = record (start here) · Redis = accelerator · Documents = escape hatch. Store sprawl is the enemy; exotic options earn their slot via benchmark (GA-20 discipline).

Course close

80 reels: PY (01-25), GA (01-30), AG (01-25). Core idea: probabilistic models → trust through evals, guardrails, budgets, gates. Keep the reels as a cross-linked reference; practice by rebuilding without looking.

Cross-links

GA-10 (Postgres/pgvector), GA-29 (Cosmos on Azure), AG-09 (guardrails), AG-14 (agent loop), AG-17 (memory), AG-19 (queues/dedupe), AG-21 (eval logs), AG-23 (rate limits/budgets), AG-25 (platform), PY-14 (pub/sub fanout, webhook dedupe), PY-16 (aggregation kinship).

Code: The last snippet of the course

# Reel 80 of 80 — the pattern that ties the course together:
# every fast system in these reels has the same skeleton.

async def serve(request):
    await guardrails.check(request)              # AG-09
    if not await rate_limit.allow(request.tenant):   # this reel
        return slow_down()

    cached = await redis.get(key(request))       # this reel
    if cached:
        return cached

    async with lock("rebuild"):                  # this reel
        result = await agent.answer(             # AG-14
            request.text,
            memory=await mongo.load(request.user),   # AG-17
            eval_log=True,                       # AG-21
        )
    await redis.set(key(request), result, ex=300)
    return result
# COURSE COMPLETE. Now go build the one only you can build.