Concept
Keeping hot data in memory, in the process or in Redis, avoids repeating expensive queries and calls. The hard part is invalidation: deciding when a cached value is stale and what to do when it is missing.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show In-memory caches doing its job.
const cache = new Map(); // key -> { value, expiresAt }
async function cached(key, ttlMs, load) {
const hit = cache.get(key);
if (hit && hit.expiresAt > Date.now()) return hit.value;
const value = await load();
cache.set(key, { value, expiresAt: Date.now() + ttlMs });
return value;
}
const rates = await cached("fx:USD", 60_000, () => fetchRates("USD"));An unbounded in-process cache that grows until the process runs out of memory. Give it a maximum size and an eviction policy, or use Redis with a TTL.
Your roadmap puts these before In-memory caches, unless you already know them.
Once a session shows you understand In-memory caches, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.