Redis (self-run or ElastiCache)
A very fast in-memory store for cached answers, counters and sessions.
Pick it when You run long-lived servers and want one shared cache with rich data types.
Skip it if You are on serverless and do not want to manage connections and a server.
- Extremely fast and very widely used
- Counters, lists, sets and rate limits built in
- Runs anywhere, including managed AWS ElastiCache
- You size, secure and monitor it
- Data is in memory, so it costs more than disk
- Quick to set up
- Cheap while small
- Easy to leave
- Room to grow
PriceFree to run yourself; managed ones charge for size and hours
How to connect it
- Run Redis, or create a managed one, and keep it on a private network.
- Set a password and never expose its port to the internet.
- Install a client and create one connection that you reuse.
- Store values with an expiry (TTL).
REDIS_URL
import { createClient } from "redis";
export const redis = createClient({ url: process.env.REDIS_URL });
await redis.connect();
await redis.set("user:42", JSON.stringify(user), { EX: 300 }); // expires in 5 min
const hit = await redis.get("user:42");