I'm getting bellow warning when using NODE_ENV=production
. What's the fix for this?
使用NODE_ENV =生产时,我收到了轰鸣声警告。有什么办法解决这个问题?
Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and obviously only work within a single process.警告:connection.session()MemoryStore不是为生产环境设计的,因为它会泄漏内存,显然只能在单个进程中工作。
1 个解决方案
#1
8
It could be a good idea to use Redis as your session manager. It appears as though you're using either the Express or Connect framework, and for either of them you could use an npm package connect-redis (having installed Redis). With that installed the express code would look something like this:
将Redis用作会话管理器可能是个好主意。看起来好像你正在使用Express或Connect框架,对于其中任何一个,你都可以使用npm包connect-redis(安装了Redis)。安装完成后,快速代码将如下所示:
var express = require ( 'express' )
, RedisStore = require ( 'connect-redis' ) ( express )
, sessionStore = new RedisStore ()
, app = express.createServer ()
;
app.configure ( function () {
app.use ( express.cookieParser () );
app.use ( express.session ( {
secret: "keyboard cat", store: sessionStore, key: 'hello.sid'
} ) );
...
#1
8
It could be a good idea to use Redis as your session manager. It appears as though you're using either the Express or Connect framework, and for either of them you could use an npm package connect-redis (having installed Redis). With that installed the express code would look something like this:
将Redis用作会话管理器可能是个好主意。看起来好像你正在使用Express或Connect框架,对于其中任何一个,你都可以使用npm包connect-redis(安装了Redis)。安装完成后,快速代码将如下所示:
var express = require ( 'express' )
, RedisStore = require ( 'connect-redis' ) ( express )
, sessionStore = new RedisStore ()
, app = express.createServer ()
;
app.configure ( function () {
app.use ( express.cookieParser () );
app.use ( express.session ( {
secret: "keyboard cat", store: sessionStore, key: 'hello.sid'
} ) );
...