Neolithic Populous Metropolis
Miss any of our Open RFC calls?Watch the recordings here! »

session-memory-store

1.0.0 • Public • Published

session-memory-store

A session store implementation for Express using node-cache.

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

And this is why I make this project, for those who want to use in-memory session, also want them to auto expire.

WANING

The session is still storing in memory, you can't share the session with others process or other service.

It's highly not recommend to use it in production!

USAGE

var express = require('express'),
  session = require('express-session'),
  cookieParser = require('cookie-parser');

// for express 4.0+
var MemoryStore = require('session-memory-store')(session);

// for express 4.0-
// var MemoryStore = require('session-memory-store')(express);

var app = module.exports = express();

app.use(cookieParser());

app.use(session({
  name: 'JSESSION',
  secret: 'my secret',
  store: new MemoryStore(options)
}));

OPTIONS

options.expires

(Number) Defined how long each session will be expired. In second. Default: half a day, 60 * 60 * 12

options.checkperiod

(Number) Defined how long MemoryStore will check for expired. In second. Default: 10 minutes, 10 * 60

Keywords

none

Install

npm i session-memory-store

DownloadsWeekly Downloads

2,300

Version

1.0.0

License

MIT

Unpacked Size

7.22 kB

Total Files

5

Last publish

Collaborators

  • avatar