简体   繁体   English

MemoryStore express.io的替代品

[英]Alternatives for MemoryStore express.io

When running node js in production mode, this warning is logged : 在生产模式下运行节点js时,将记录以下警告:

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 . 经过简短的研究,我发现我应该通过传递express-session-mongoexpress-session-redis来使用其他替代方法来存储会话

My questions : 我的问题:

  • Are this solutions built for expressJs working with express.io ? 该解决方案是否为与express.io一起使用的expressJ构建?
  • 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. 如您所见,使用其中之一将迫使我安装mongo或redis,这对我而言不是很好。

Thank You ! 谢谢 !

I resolved it by using the cookie-session library, i simply flowed the tutorial. 我使用cookie-session库解决了这个问题,我只是简单地进行了本教程。
cookie-session on github github上的cookie会话

I would highly suggest backing your session's with a database. 我强烈建议您使用数据库来支持您的会话。 I would use Redis, CouchDB/Cloudant, memcached, or Mongo. 我会使用Redis,CouchDB / Cloudant,memcached或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. 请访问http://passportjs.org/ ,其中有一些模块可帮助您将会话数据存储到外部资源中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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