v2.2.1 — Mongoose query and aggregate caching plugin supporting in-memory and Redis backends. Integrates via a .cache() method on Mongoose Query and Aggregate instances, with configurable TTL by string or number (seconds). Peer dependencies: mongoose (6.6-9.x), bson, and optional @nestjs/common. Tested against mongoose 6.12.2, 7.6.4, 8.23.0, and 9.4.1. Key differentiator: minimal API surface, ESM + CJS, TypeScript-first, with built-in bounded in-memory cache option.
npm install ts-cache-mongooseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initialize the plugin with in-memory caching, run a cached query and aggregate.
Use .cache('30 seconds') instead of .cache({ ttl: '30 seconds' })Upgrade to >=2.2.0 and configure bounded cache via engineOptions.maxKeys
Verify mongoose version with 'npm ls mongoose' and install compatible version
Upgrade Node.js to >=20
Run 'npm install ts-cache-mongoose mongoose' and ensure import path is correct
Use 'import cache from 'ts-cache-mongoose'' or enable ESM in your project
Ensure 'await mongoose.connect(...)' completes before executing queries