What is a good session store for a single-host Node.js production app?

后端 未结 8 1461
太阳男子
太阳男子 2020-11-29 15:38

I\'m using Node\'s Express w/ Connect middleware. Connect\'s memory session store isn\'t fit for production:

Warning: connection.session() Memo         


        
8条回答
  •  温柔的废话
    2020-11-29 16:04

    Another good option is memcached. The session states are lost if memcached is restarted, but there is virtually never any reason to do that. You can leave the cache running all the time even when you restart your app server. Access to the session data is virtually instantaneous and memcached will run happily with whatever (appropriate) amount of memory you give it. And I've never seen memcached crash (on Linux).

    https://github.com/elbart/node-memcache

    Things to keep in mind about memcached generally:

    • Never have whitespace in your cache keys
    • Be aware that there is a maximum cache key length, including any namespace prefix you might use. If your cache key is too long, use a 1-way hash of it instead.

    Neither of these should be an issue with session storage; just with generalized caching.

提交回复
热议问题