Registry / storage / express-session-cache-manager

express-session-cache-manager

JSON →
library1.0.2jsnpmunverified

An Express session store that leverages node-cache-manager, allowing you to plug in any supported caching backend (Redis, Memcached, MongoDB, etc.) with a unified API. Version 1.0.2 is the latest stable release; the package is updated infrequently. It provides a clean integration for Express sessions with flexible storage options, unlike express-session's default MemoryStore, which is not suitable for production.

npm install express-session-cache-manager
INSTALL
IMPORT
SIG · EXPRESS-SESSION-CA
E
express-session-cache-manager
storagejavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CacheManagerStore
import CacheManagerStore from 'express-session-cache-manager'
const { CacheManagerStore } = require('express-session-cache-manager')
The package uses a default export; named import will not work.
Express Session Store Configuration
const store = new CacheManagerStore(cacheManager.caching({ store: memoryStore }))
const store = new CacheManagerStore(cacheManager.caching({ store: 'memory' }))
The 'store' option must be a cache-manager store engine instance, not a string.
CommonJS require
const CacheManagerStore = require('express-session-cache-manager').default
const CacheManagerStore = require('express-session-cache-manager')
For CommonJS, access the .default property due to the ES module default export.

Sets up Express with a session store backed by cache-manager (using in-memory store) and tracks page views.

import express from 'express'; import session from 'express-session'; import cacheManager from 'cache-manager'; import CacheManagerStore from 'express-session-cache-manager'; import memoryStoreEngine from 'cache-manager-memory-store'; const app = express(); const sessionMiddleware = session({ store: new CacheManagerStore(cacheManager.caching({ store: memoryStoreEngine })), secret: process.env.SESSION_SECRET || 'your-secret' }); app.use(sessionMiddleware); app.get('/', (req, res) => { if (!req.session.views) req.session.views = 0; req.session.views++; res.send(`Views: ${req.session.views}`); }); app.listen(3000);
Debug
Known issues
breakingDefault export changed from constructor to a class requiring 'new'; named export was removed in v1.0.0.
fix
Use 'import CacheManagerStore from 'express-session-cache-manager'' and instantiate with 'new'.
affects: <1.0.0
deprecatedThe 'ttl' option is deprecated; use cache-manager's built-in TTL configuration instead.
fix
Set TTL in the cache-manager caching options (e.g., cacheManager.caching({ store, ttl: 3600 })).
affects: >=1.0.0
gotchaDo not use this store with the default MemoryStore from express-session; it is intended for production stores like Redis.
fix
Use a cache-manager store engine (e.g., cache-manager-redis) instead of express-session's MemoryStore.
affects: >=1.0.0
gotchaThe store does not support session 'touch' method, which may cause issues with rolling session expiration.
fix
Implement custom session middleware or use a store that supports 'touch'.
affects: >=1.0.0
deprecatedThe 'clear_expired' method is no longer available; use cache-manager's own cache cleanup instead.
fix
Remove calls to 'clear_expired'.
affects: <1.0.0
Errors
Common errors & fixes
TypeError: CacheManagerStore is not a constructor
Using named import instead of default import.
fix
Change import to default import: import CacheManagerStore from 'express-session-cache-manager'
Error: Invalid store type: must be an object with get/set/del methods
Passing a string or invalid store engine to cache-manager.
fix
Ensure you pass a valid cache-manager store engine instance (e.g., cache-manager-redis).
Error: Cannot find module 'cache-manager'
Missing peer dependency cache-manager.
fix
Install cache-manager: npm install cache-manager
Error: express-session is not a peer dependency of this package
Missing express-session installation.
fix
Install express-session: npm install express-session
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
express-sessionrequiredpeer dependency; the session store is designed to work with express-session middleware
cache-managerrequiredpeer dependency; provides the caching API and store abstraction
Agent activity
14 hits · last 30 days
node
12
Resources
express-session-cache-manager — npm install express-session-cache-manager · libregistry