An Express.js + TypeScript API that fetches product data from MongoDB and caches the result using ioredis for improved performance.
Ideal for learning Redis caching, API optimization, and working with Mongoose models.
- Fetches product data using Mongoose
- Redis caching with automatic fallback
- TypeScript, Express, and ioredis integration
- JSON response optimization
- Cache expires every 30 seconds
- Node.js
- Express.js
- TypeScript
- MongoDB + Mongoose
- Redis (via ioredis)
git clone https://github.com/developersajadur/Redis-Cache-Learning
cd Redis-Cache-Learning- Install Dependencies
npm install- Create .env File
PORT=5000
DATABASE_URL=your-mongodb-uri- Install & Run Redis β Option 1: Download Redis for Windows Download the Redis-x64-3.2.100.zip or similar
Extract it and run redis-server.exe (You can add it to PATH or run from CMD directly)
β Option 2: Use Docker (Recommended)
docker run --name redis-server -p 6379:6379 -d redis- Run the Project
npm run devπ Development Scripts Script Description npm run dev Start app in dev mode npm run build Compile TypeScript npm start Run compiled app
π Useful Links π ioredis NPM: https://www.npmjs.com/package/ioredis
π§± Redis for Windows: https://github.com/microsoftarchive/redis/releases
π¦ Redis Docker Image: https://hub.docker.com/_/redis