screenshot of Memorystore


express-session full featured MemoryStore layer without leaks!


The memorystore is a full-featured MemoryStore module with a focus on preventing memory leaks for Express session storage. It provides a session store implementation for Express using lru-cache, offering options for TTL, cache size settings, and more.


  • Prevents Memory Leaks: Provides a way to avoid memory leaks that can occur with the default MemoryStore in express-session.
  • Customizable Options: Allows users to define settings such as check period, maximum cache size, session TTL, and more.
  • Additional Methods: Implements required, recommended, and optional methods for the express-session store, with extras like startInterval, stopInterval, and prune.


To install the memorystore package in your Node.js project, you can use npm:

npm install memorystore

When setting up the Express session, pass the memorystore instance as the store:

const session = require('express-session');
const MemoryStore = require('memorystore')(session);

  store: new MemoryStore({
    checkPeriod: 300000, // example check period in ms
    max: 1000, // example max cache size
    ttl: 86400000 // example session TTL in ms
  secret: 'your_secret_key',
  resave: false,
  saveUninitialized: true


The memorystore package provides a reliable solution for managing session storage in Express applications, offering features to prevent memory leaks, customize cache settings, and implement necessary session store methods. With additional methods like startInterval and stopInterval, it adds value to the Express session handling process. The package is authored by Rocco Musolino and is licensed under MIT.


Express.js is a simple Node.js framework for single, multi-page, and hybrid web applications.