HttpSession 数据存储在哪里? [英] Where is the HttpSession data stored?

查看:339
本文介绍了HttpSession 数据存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HttpSession 是一个建立在 cookie 和 url-rewriting 之上的高级接口,这意味着只有一个 session ID 存储在客户端,与之相关的数据存储在服务器一边.

HttpSession is a high level interface built on top of cookies and url-rewriting, which means that there is only a session ID is stored in client side and the data associated with it is stored in server side.

HttpSession 的数据实际上存储在服务器端在哪里?在JVM内存或其他地方?我可以改变存放它的地方吗,例如将它们保存到内存数据库中?

Where is the HttpSession data actually stored in the server side? In the JVM memory or somewhere else? Can I change the place where to store it, e.g. save them into an in-memory database?

如果不是在数据库中,当多个客户端同时处理同一个会话数据时,是否存在并发问题?

If it's not in a database, is there any concurrency problem when many clients work on the same session data at the same time?

推荐答案

存储会话数据的位置取决于服务器;我熟悉的那些允许对会话数据的存储位置(磁盘、数据库、内存等)进行某种级别的配置.

It's up to the server where to store session data; the ones I'm familiar with allow some level of configuration as to where (disk, DB, memory, ...) session data is stored.

不同的客户端不应该处理相同的会话数据——会话数据是针对每个客户端的.也就是说,单个客户端(如网络浏览器)可能会打开多个窗口或选项卡,是的,这可能会导致问题.

Different clients shouldn't be working on the same session data--session data is per-client. That said, a single client (like a web browser) could have multiple windows or tabs open, and yes, that can cause issues.

由于会话数据在服务器之间共享,因此集群增加了一层复杂性/令人头疼的问题.

Clustering adds a layer of complexity/headache as session data is shared between servers.

这篇关于HttpSession 数据存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆