Memorystore

screenshot of Memorystore
express

Memorystore

express-session full featured MemoryStore layer without leaks!

Overview:

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.

Features:

  • 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.

Installation:

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);

app.use(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
}));

Summary:

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
Express

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

fullstack
Fullstack Boilerplates

A fullstack boilerplate provides a starter application that includes both frontend and backend. It should include database, auth, payments, user roles and other backend services to build a fully featured saas or webapps.