java session save,java - Spring Session中的SaveMode和FlushMode有什么区别? - 堆栈内存溢出...

春季会议有两个枚举一个叫SaveMode和一个叫FlushMode的参考文档不作SaveMode和冲洗模式的任何提及。 听起来javadoc的描述非常相似。

保存模式和刷新模式究竟能控制什么?

在哪些情况下需要显式设置SaveMode和Flush模式?

保存模式

/**

* Supported modes of tracking and saving session changes to session store.

*

* @author Rob Winch

* @author Vedran Pavic

* @since 2.2.0

*/

public enum SaveMode {

/**

* Save only changes made to session, for instance using

* {@link Session#setAttribute(String, Object)}. In highly concurrent environments,

* this mode minimizes the risk of attributes being overwritten during processing of

* parallel requests.

*/

ON_SET_ATTRIBUTE,

/**

* Same as {@link #ON_SET_ATTRIBUTE} with addition of saving attributes that have been

* read using {@link Session#getAttribute(String)}.

*/

ON_GET_ATTRIBUTE,

/**

* Always save all session attributes, regardless of the interaction with the session.

* In highly concurrent environments, this mode increases the risk of attributes being

* overwritten during processing of parallel requests.

*/

ALWAYS

}

冲洗模式

/**

* Supported modes of writing the session to session store.

*

* @author Rob Winch

* @author Vedran Pavic

* @since 2.2.0

*/

public enum FlushMode {

/**

* Only writes to session store when {@link SessionRepository#save(Session)} is

* invoked. In a web environment this is typically done as soon as the HTTP response

* is committed.

*/

ON_SAVE,

/**

* Writes to session store as soon as possible. For example

* {@link SessionRepository#createSession()} will write the session to session store.

* Another example is that setting an attribute using

* {@link Session#setAttribute(String, Object)} will also write to session store

* immediately.

*/

IMMEDIATE

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值