Gathering detailed insights and metrics for memorystore
Gathering detailed insights and metrics for memorystore
Gathering detailed insights and metrics for memorystore
Gathering detailed insights and metrics for memorystore
express-session full featured MemoryStore layer without leaks!
npm install memorystore
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
120 Stars
89 Commits
23 Forks
5 Watching
2 Branches
6 Contributors
Updated on 18 Sept 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-0.7%
14,586
Compared to previous day
Last week
2.7%
93,901
Compared to previous week
Last month
28.9%
345,566
Compared to previous month
Last year
-0.2%
3,525,904
Compared to previous year
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.
$ npm install express-session memorystore
Pass the express-session
store into memorystore
to create a MemoryStore
constructor.
1const session = require('express-session') 2const MemoryStore = require('memorystore')(session) 3 4app.use(session({ 5 cookie: { maxAge: 86400000 }, 6 store: new MemoryStore({ 7 checkPeriod: 86400000 // prune expired entries every 24h 8 }), 9 resave: false, 10 secret: 'keyboard cat' 11}))
checkPeriod
Define how long MemoryStore will check for expired. The period is in ms. The automatic check is disabled by default! Not setting this is kind of silly, since that's the whole purpose of this lib.max
The maximum size of the cache, checked by applying the length
function to all values in the cache. It defaults to Infinity
.ttl
Session TTL (expiration) in milliseconds. Defaults to session.maxAge (if set), or one day. This may also be set to a function of the form (options, sess, sessionID) => number
.dispose
Function that is called on sessions when they are dropped
from the cache. This can be handy if you want to close file
descriptors or do other cleanup tasks when sessions are no longer
accessible. Called with key, value
. It's called before
actually removing the item from the internal cache, so if you want
to immediately put it back in, you'll have to do that in a
nextTick
or setTimeout
callback or it won't do anything.stale
By default, if you set a maxAge
, it'll only actually pull
stale items out of the cache when you get(key)
. (That is, it's
not pre-emptively doing a setTimeout
or anything.) If you set
stale:true
, it'll return the stale value before deleting it. If
you don't set this, then it'll return undefined
when you try to
get a stale entry, as if it had already been deleted.noDisposeOnSet
By default, if you set a dispose()
method, then it'll be called whenever a set()
operation overwrites an existing key. If you set this option, dispose()
will only be called when a key falls out of the cache, not when it is overwritten.serializer
An object containing stringify
and parse
methods compatible with Javascript's JSON
to override the serializer used.memorystore
implements all the required, recommended and optional methods of the express-session store. Plus a few more:
startInterval()
and stopInterval()
methods to start/clear the automatic check for expired.
prune()
that you can use to manually remove only the expired entries from the store.
To enable debug set the env var DEBUG=memorystore
Rocco Musolino (@roccomuso)
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
Found 6/24 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More