Skip to content

A Node.js demo showcasing Redis caching for enhanced performance, utilizing the JSONPlaceholder Photos API for efficient data retrieval.

Notifications You must be signed in to change notification settings

SebastianTianying/Redis-Caching-For-NodeJS

Repository files navigation

Redis-Caching-For-NodeJS

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.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Before running the application, make sure you have Node.js installed on your system.

Installing

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

Running the Application

Start the Redis server:

redis-server

Then start the application:

npm start

Connect to the Redis server using the CLI:

redis-cli

Built With

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.\

Development Tools

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.\

DEMO

Initial Query: cache missed, long query time image

Second Query: cache hit, super fast query time with the Redis! image

Console logging cache miss or hit after each query request with Redis image

Similar for query with specific parameters: image

Significant improvement in process time with Redis! image

Data Sources

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.

Acknowledgments

Certain parts in this project follows tutorials from Web Dev Simplified - Create Your Own Postman and Redis Crash Course.

About

A Node.js demo showcasing Redis caching for enhanced performance, utilizing the JSONPlaceholder Photos API for efficient data retrieval.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published