@spurtcommerce/redis-cache
v1.0.4
Published
Auto Redis caching middleware for Express routes using global app.use()
Maintainers
Readme
@spurtcommerce/redis-cache
🔥 Effortless Redis-based API caching for Express.js
This package allows you to cache specific API responses in Redis with minimal configuration. Just plug it in, specify your routes and TTLs (in seconds), and you're good to go — Boom! Cache is integrated.
✨ Features
- Super easy to integrate
- Route-specific TTL configuration
- Global middleware for clean architecture
- Powered by Redis
📦 Installation
npm install @spurtcommerce/redis-cacheSample Code
import { initRedis, cacheMiddleware } from '@spurtcommerce/redis-cache';
await initRedis(REDIS_URL);
app.use(
cacheMiddleware({ // Mention the Reqiured Api path to cache with duration in seconds
'/api/list/banner': 5,
'/api/list/language': 5,
'/api/pages': 5,
'/api/list/blog/blog-list': 5,
})
);