Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Store hot data and sessions in Redis for speed and scale.
Caching with Redis is easiest to learn by reading the example, changing it, and observing the result.
// npm install redis
import { createClient } from 'redis';
const redis = createClient({ url: process.env.REDIS_URL });
await redis.connect();
async function getLessons() {
const cached = await redis.get('lessons');
if (cached) return JSON.parse(cached);
const fresh = await db.lessons.findMany();
await redis.set('lessons', JSON.stringify(fresh), { EX: 60 });
return fresh;
}Practice the Caching with Redis example in a small scratch file, then explain what changed and why.