Skip to content

DhavalBhimani44/basic-redis-caching

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis Caching API with Express.js and Axios

This project is a simple demonstration of how to cache API responses using Redis in a Node.js (Express) server. It uses the JSONPlaceholder API to fetch photo data and caches it for faster repeat access.


✨ Features

  • Fetch and cache list of photos (/photos?albumId=1)
  • Fetch and cache individual photo by ID (/photos/:id)
  • Caching powered by Redis with expiration time
  • Simple and clean middleware logic
  • Uses Axios for HTTP requests

♻ Tech Stack


⚙ Setup Instructions

1. Clone the Repository

https://github.com/your-username/basic-redis-caching.git
cd basic-redis-caching

2. Install Dependencies

npm install

3. Setup Redis Locally (in short)

You can install Redis quickly depending on your OS:

brew install redis
brew services start redis
  • Ubuntu/Linux:
sudo apt update
sudo apt install redis-server
sudo systemctl enable redis-server.service
  • Verify Redis:
redis-cli ping  # Output should be: PONG

Detailed Redis installation guide: https://redis.io/docs/getting-started/installation/

4. Start the Server

nodemon server.js

Server runs on http://localhost:3000


📂 API Endpoints

GET /photos?albumId=1

  • Fetches all photos from album 1
  • Response is cached for 1 hour (3600s)

GET /photos/:id

  • Fetches a single photo by ID
  • Response is cached individually

✉ Contributing

Pull requests welcome! For major changes, open an issue first to discuss what you want to change.


❤️ Credits

Built by Dhaval Bhimani with ☕ and a lot of curiosity.


👉 Related Links

About

Simple Redis caching setup to boost API/data retrieval performance. Demonstrates how to store, fetch, and expire cached data efficiently.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors