春季安全策略MODE

编程入门 行业动态 更新时间:2024-10-27 17:22:15
春季安全策略MODE_INHERITABLETHREADLOCAL。(spring security strategy MODE_INHERITABLETHREADLOCAL. Why?)

我理解当我们在Spring Security Strategy中使用MODE_THREADLOCAL和MODE_INHERITABLETHREADLOCAL时会发生什么以及会发生什么。 我不明白的是,为什么有人会使用MODE_THREADLOCAL而不是MODE_INHERITABLETHREADLOCAL。

使用一个而不是另一个会对内存产生影响。 如果是这样,它是否足够重要? 使用MODE_INHERITABLETHREADLOCAL的典型业务/功能用例是什么? 任何表现与使用其中一个不同?

I understand how and what happens when we use MODE_THREADLOCAL and MODE_INHERITABLETHREADLOCAL in Spring Security Strategy. What I don't understand is, why would someone use MODE_THREADLOCAL over MODE_INHERITABLETHREADLOCAL.

Is there a memory impact with using one over the other. If so, is it significant enough? What is a typical business/functional usecase for using MODE_INHERITABLETHREADLOCAL? Any performance different with using one over the other?

最满意答案

使用这两者的记忆影响可以忽略不计

在某些环境中,通常会启动新线程来执行后台任务。 有时开发人员不希望创建的Thread自动包含SecurityContext。 在这些情况下,最好使用MODE_THREADLOCAL。 如果代表当前用户启动任务,则可能需要传播SecurityContext。 在这种情况下,MODE_INHERITABLETHREADLOCAL将是首选的。

两种策略之间的表现可以忽略不计

The memory impact of using the two is negligible

In some environments, it is common to spin up new Threads to do background tasks. Sometimes developers do not want the Thread that is created to contain a SecurityContext automatically. In these instances, MODE_THREADLOCAL is preferable. If you spin up a task on behalf of the current user, then it may be desirable to propagate the SecurityContext. In this instance MODE_INHERITABLETHREADLOCAL would be preferrable.

Performance between the two strategies is negligible

更多推荐

本文发布于:2023-07-28 04:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1300366.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:安全策略   春季   MODE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!