Redis Short Course
Note on Redis Short Course
5 min read
Published May 16, 2026
Tech Notes
01-What is Redis and why it exists
Introduction of redis




- Read query will optimised
- same data, hot data, response fast
- example (zomato, blinkit menu)
Features provided by redis
Cache

Session Store

OTP Store

Rate Limiting

JOB Queue

Redis
In redis everthing is stored in key value pair. redis is also known as key value store.

TTL ⇒ is very imprtant in redis

Note ⇒ Redis is not a solution for every problem.
02-Complete local setup to learn Redis
docker-compose.yml
services:
redis:
image: redis:7-alpine
container_name: redis-container
ports:
- "6379:6379"
volumes:
- redis-data:/data
mongo:
image: mongo:7
container_name: mongodb
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db
volumes:
redis-data:
mongo-data:
server.js file
import express from "express";
import "dotenv/config";
import Redis from "ioredis";
import mongoose from "mongoose";
const app = express();
const redis = new Redis(process.env.REDIS_URL);
const PORT = process.env.PORT;
app.use(express.json());
app.get("/", (_, res) => {
res.send("welcome to server...");
});
app.post("/setOtp", async (req, res) => {
try {
console.log("body is:", req.body);
const { otp } = req.body;
await redis.set("otp", otp);
res.json({
msg: "otp set",
});
} catch (error) {
console.log("error during otp save", error);
}
});
app.listen(PORT, () => console.log(`server is running on port:${PORT}`));
package.json file
{
"name": "redis-chaicode",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "npx nodemon src/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "module",
"dependencies": {
"dotenv": "^17.4.2",
"express": "^5.2.1",
"ioredis": "^5.10.1",
"mongoose": "^9.6.2"
}
}
.env file
PORT="3000"
REDIS_URL="redis://localhost:6379"