Use cases and boundaries
Use the memory cache for local, bounded reads. Read-through helpers and tags give callers a place to centralize miss handling and invalidation. Set keys around the scope of the data they represent and choose whether cross-process coordination is necessary.
Getting started and compatibility
Install the released package
npm install cache-hub@2.2.5
npm package cache-hub v2.2.5 requires Node.js 18+. Memory use needs no Redis. Redis-backed features require a configured backend and the optional ioredis peer. TTL and invalidation do not make the cache the authority for business data.
import { MemoryCache } from 'cache-hub';
const cache = new MemoryCache({ maxEntries: 100, defaultTtl: 15_000 });
await cache.set('public:daily-reports', ['weekday']);
console.log(await cache.get('public:daily-reports'));