问题
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