Today I ran my Node.js application in “production” mode for the first time and got this warning:
Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and obviously only work within a single process.
I only need to run a single process, but what should I use instead? I want my sessions to reside in RAM for fast access. I also want to be able to discard all the sessions by simply shutting down the Node app.
It seems an overkill to install Redis, MongoDB or another database just for this simple task. I also don’t understand why is MemoryStore included in Node when it should not really be used?
MemoryStore is just for (rapid) development mode, because if your app restarts (process dies) you will lose all the session data (that resided in the memory of that process).
If you don’t want to use a database, use encrypted cookie storage instead.
http://www.senchalabs.org/connect/cookieSession.html