In memory storage on nodejs server

天涯浪子 提交于 2019-12-04 15:13:34

The dependencies for express-session are right on Github in its package.json. I don't see any of your listed storage mechanisms.

Then, if you look at the code for the MemoryStore object here, you can see that it's just using a Javascript object to store a list of sessions indexed by sessionId.

"Which one is better" depends on your requirements such as traffic volume, how much you want to store in-memory cache etc.

When you select an in-memory store, keep in mind node.js is single-threaded and for-loops are blocking codes. If you look at the source for most of these packages such as node-cache, they all have for-loops, iterating through all your cached items for TTL check. So if you store 10000 objects, your app is going to be blocked until 10k iteration is completed. So beware of your choice.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!