This project is a Node.js application that leverages Redis for caching to significantly improve performance. It is specifically designed to showcase how Redis can be integrated with a Node.js backend to accelerate data retrieval processes.
For demonstration purposes, the application fetches placeholder photos from the JSONPlaceholder's Photos endpoint, a free online REST API that provides dummy data suitable for testing and prototyping web applications.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Before running the application, make sure you have Node.js installed on your system.
To set up the project, run the following commands in your terminal:
# Initialize the project
npm init -y
# Install dependencies
npm install axios express cors redis
# Install development dependencies
npm install --save-dev snowpack concurrently nodemon
# Install Bootstrap for frontend styling
npm install bootstrap
Start the Redis server:
redis-server
Then start the application:
npm start
Connect to the Redis server using the CLI:
redis-cli
Node.js - The JavaScript runtime used.
Express - The web application framework.
Redis - The in-memory data structure store used as a database and cache.
Axios - Promise-based HTTP client for making HTTP requests.
Bootstrap - Frontend framework for building responsive, mobile-first sites.\
Snowpack - A modern, lightweight build tool for faster development builds.
Concurrently - A utility that manages multiple processes concurrently.
Nodemon - A tool that automatically restarts the node application when file changes in the directory are detected.\
Initial Query: cache missed, long query time
Second Query: cache hit, super fast query time with the Redis!
Console logging cache miss or hit after each query request with Redis
Similar for query with specific parameters:
Significant improvement in process time with Redis!
This application fetches data from the following external API:
JSONPlaceholder Photos API: The application uses the JSONPlaceholder's Photos endpoint (https://jsonplaceholder.typicode.com/photos) to retrieve placeholder photos for demonstration purposes.
Certain parts in this project follows tutorials from Web Dev Simplified - Create Your Own Postman and Redis Crash Course.