简体   繁体   中英

Alternatives for MemoryStore express.io

When running node js in production mode, this warning is logged :

Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.

Doing a brief research, i found that i should use other alternatives for session storage by passing express-session-mongo or express-session-redis .

My questions :

  • Are this solutions built for expressJs working with express.io ?
  • Is there a solution to solve the problem without using one of theese ? As you can see, using one of them will force me to install mongo or redis which is not good in my case.

Thank You !

I resolved it by using the cookie-session library, i simply flowed the tutorial.
cookie-session on github

I would highly suggest backing your session's with a database. I would use Redis, CouchDB/Cloudant, memcached, or Mongo.

The reason express is giving that error is the in memory database is only available on the current node you are running and if you scale your application the session data will not be available on other nodes.

Check out http://passportjs.org/ , there are some modules to help you store the session data into an external resource.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM