Mongoose Cache is a lightweight module that adds integrated Redis caching to Mongoose queries for Node.js. Version 1.1.1 is the latest stable release; the package is in maintenance mode with irregular updates. It wraps Mongoose query executors to cache results in Redis using a simple .cache(ttlSeconds, customKey) method. Unlike more complex caching solutions (e.g., cachegoose), it aims for minimal configuration and direct Redis URL connection. It supports Mongoose 5.x+ and works with both callback and async/await patterns. Key differentiator: dead-simple API—just call .cache() on any query chain. No support for cache invalidation by pattern or automatic expiration of stale keys beyond TTL.
npm install mongoose-redisNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to MongoDB and Redis, attaches caching to Mongoose, then runs a cached find query with 60-second TTL.
Manually clear cache keys using a custom key pattern and redisClient.del() after write operations.
Monitor Redis connection events (connect, error) and set up fallback logging.
Pin Mongoose to version 5.x or 6.x, or switch to a more maintained caching solution.
Consider using `@redis/client` directly and rewriting the caching layer, or migrate to a maintained fork.
Always call .cache() after all other chain methods and before await/exec.
Call MongooseCache(mongoose, redisUrl) without new.
Ensure MongooseCache(mongoose, url) is called after mongoose.connect() and before defining models.
Double-check that MongooseCache was called with the correct mongoose instance and Redis URL.
Start a Redis server (e.g., redis-server) or update the connection URL (set REDIS_URL environment variable).