Home

Awesome

memorystore NPM Version node Build Status JavaScript Style Guide

express-session full featured MemoryStore module without leaks!

A session store implementation for Express using lru-cache.

Because the default MemoryStore for express-session will lead to a memory leak due to it haven't a suitable way to make them expire.

The sessions are still stored in memory, so they're not shared with other processes or services.

Setup

$ npm install express-session memorystore

Pass the express-session store into memorystore to create a MemoryStore constructor.

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

app.use(session({
    cookie: { maxAge: 86400000 },
    store: new MemoryStore({
      checkPeriod: 86400000 // prune expired entries every 24h
    }),
    resave: false,
    secret: 'keyboard cat'
}))

Options

Methods

memorystore implements all the required, recommended and optional methods of the express-session store. Plus a few more:

Debug

To enable debug set the env var DEBUG=memorystore

Author

Rocco Musolino (@roccomuso)

License

MIT