两个Map,一个根据SessionId,找到Session;一个在session内部,通过 key,找到value
最简单的标准会话应该包括 ID 和 Map<String,Object> 结构的属性。ID 用于表示会话编号,它必须是全局唯一的,属性用于存储会话相关信息,以 KV 结构存储
使用ConcurrentHashMap保存数据
ManagerBase
// 保存根据sessionId,找session
protected Map<String, Session> sessions = new ConcurrentHashMap<String, Session>();
StandardSession
// 在session下,根据key找value
protected ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<String, Object>();
StandardSession
- impl HttpSession Serializable Session, HttpSession JavaEE标准类
- StandardSessionFacade 门面模式对外暴露类
SessionIdGenerator
- sessionId:16个字节,32位
BackgroundProcess
- 定期清扫过期的session