What is the use of a session store?

大城市里の小女人 提交于 2019-12-10 23:08:53

问题


I am using koa and passport therefore I am using the koa-generic-session middleware to handle my sessions.

Now unlike the expressjs session middleware there isn't a big disclaimer in the documentation like such : The default server-side session storage, MemoryStore, is purposely not designed for a production environment.

Assuming the MemoryStore for the koa-generic-session is ready for production use, why would I use a heavy duty session store such as mysql or mongodb for sessions that come and go all day long? What additional capabilities would using one give me that MemoryStore doesn't?


回答1:


In memory session store works perfectly for development but it has a couple of caviats for production use.

  • restarting the server causes all sessions to be invalidated, this is not nice for the users of your application
  • in memory store is not efficient handling production level loads where there are potentially huge amounts of sessions ongoing at the same time, therefore a more efficient storage is better that writes to disks, caches frequently used. a database would fulfill all these qualities


来源:https://stackoverflow.com/questions/33280176/what-is-the-use-of-a-session-store

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